Posts

How to disable enable action on page dynamically on user selection in Business central

  Disable / Enable Action  on Page with some Value. I came up to an requirement of enabling and disabling action coming on business central page and that should be on basis of some value i.e. I have list page of variants and i want to disable my action (Xyz) on that page if user has selected some variant named as Abc and if not then it should be enable likewise. Note : I used the property "Enabled" of actions in business central and acquired my need by binding it to some boolean variable that is having value true or false on some condition. And doing that whole story in page trigger  onaftergetcurrrecord() that is the trigger which is fired every time when user does some selection on list.  Here is the code snippet of my page extension. Code example : pageextension   50143  VariantListPageExt  extends  "Item Variants" {      layout     {          // Add ...

How To do Hashing HMAC RSA 1 algorithm or cryptography in Microsoft Business Central | AL Code

HMAC RSA-1 Hashing In AL code | Cryptography Management in Business Central | O AUTH 1.0 Signature Making in Business Central I came up to an requirement of consuming Rest api with O Auth 1.0 authentication in Business Central AL Code and ended up on a point where i have to do some hashing with some defined algorithm to make signature key for my request...  ðŸ˜’ Don't be upset with my story simple is that just do cryptography just by passing your text and password and algorithm of your choice. Read more for the available functions available as cryptography management Code Unit in BC | AL action( hash )  { ApplicationArea = All;     trigger  OnAction ()       var      CryptographyManagement:  Codeunit  "Cryptography Management";      HashAlgorithmType:  Option  MD5,SHA1,SHA256,SHA384,SHA512;   begin      Message ( 'Decrypt %1' ,...

Consume Rest API in Business Central Code with Basic Auth

 Rest API Call With Basic Auth | Woo Commerce Rest API So i was working on some requirement of pushing products directly form Microrosft Business Central  to E-Commerce side i.e WOO-Commerce. so what we need is to consume the woo side API's into our AL code (BC SIDE) that requires the basic auth in case of https authentication. Here is a glimpse of code for understanding or picking some approach for the others seeking something like that in Business Central.   action( UnixTimestamp )             {                 ApplicationArea = All;                  trigger  OnAction ()                  var            ...

How to get Hours, Minutes or seconds from Time Data Type in Business Central | AL Code | NAV

 Format Time Data Type To Hours, Minutes or Seconds So we have Time suppose System Current Time in Time data type as follows and what we need is to get only hours minute or seconds out of the Time value that is formatting it into some text expression like.                                           22 hours 34 minutes 5 seconds  or whatever you are getting in other planets but i have same solution for you aliens.👽    var                  MySysTime:  Time ; begin MySysTime := Time; Message('Regular Time printing as : %1', MySysTime ); //Formatting into parts separtely                        message('Current hours %...

How to get nonce for rest Api call in Business Central AL Code.

How To Create Nonce for Rest API Call In Business Central Nonce is a random piece of string generated every time for web services call that require nonce in their header part i.e O Auth 1.0 uses nonce to be included in their header request, each time they are random and different for the call purpose. Scenario : I need the same random alphanumeric piece of string for the call so what i did was to use a  CREATEGUID, copystr and  DELCHr  methods already included in Business Central side. For detail please read Microsoft Documentation to be clear about methods used . 💥💪 trigger  OnAction ()                  begin                     RandomDigit  :=  CREATEGUID;                     Ra...

Reading json data in Business Central

  Read JsonObject In Buisness Central AL Code The following code is an example of how to read properties from a JsonObject. It is reading properties of the Json Object . * Also reading text into json object as a bonus to our readers 👽 Scenario: We are having simple Json value in a text type variable as an text and then reading out in a json object for having key and value properties so we can show it here how we are finding the key and value pair.      var        jsontext :  text ;        jsonobj :  JsonObject ;        JOrderNoToken:  JsonToken ;      begin           jsontext :=  '{"name": "test2908"}'; //  reading text value in json object        jsonobj . readfrom ( responseText ) ;             //  Now finding key and his value from json ...