Learning proper AL formatting

  • Learning proper AL formatting

    Posted by Jason Wilder on October 4, 2018 at 12:15 pm
    • Jason Wilder

      Member

      October 4, 2018 at 12:15 PM

      Anyone have some good websites that can assist with learning proper formatting and naming in AL?Ā  This is a good place to start but I need more: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/compliance/apptest-bestpracticesforalcode.

      It is less about the language itself as it is still C/AL, it is more the structure and naming of the files and the objects and the best way to format certain statements (yes I am using the Format Document command).Ā  To narrow the focus for now I am only working on Page Extensions if that helps.

      ——————————
      Jason Wilder
      Senior Application Developer
      Stonewall Kitchen
      York ME
      ——————————

    • Cheyanne Peters

      Member

      October 5, 2018 at 5:44 AM

      Hello Jason,

      I’m not aware of documentation beyond what it seems you have already found. Have you tried turning on code analysis? There are some additional rules used in the analyzers that I don’t see mentioned on that page (or in other tabs under that AL group). TheĀ PerTenantExtensionCop analyzer will complain if you are not using the custom extension range and are using Internal for the Target property. However it also has some other rules that are useful.Ā 

      Using the Code Analysis Tool – Business Central

      ——————————
      Cheyanne Peters
      Technical Operations Manager
      Insight Works
      ——————————
      ——————————————-

    • Jason Wilder

      Member

      October 5, 2018 at 1:22 PM

      I have not looked into code analysis, thanks for the link!

      I few other things that I haven’t seen readily available that might help others:

      Custom objects when imported into NAV 2018 (from your previous version) default a new property called FunctionVisibility to Internal.Ā  This means if you try to reference this in AL it will say “The type or method ‘xxx’ cannot be used for Extension developement”.Ā  The fix is to simply change the FunctionVisibility property to External.Ā  Reload your symbols and all will be good.

      In the classic C/AL Developer Environment if you compile an object by default it will not generate the needed AL metadata required for the object to be seen in AL.Ā  I had a codeunit that I could reference in AL, but then I compiled in C/AL and then could no longer see in AL.Ā  The fix is to make sure your classic developer environment has a property on the shortcut set called generatesymbolreference=yes.Ā  This will compile the AL metadata when you compile the object so AL will be able to reference it.

      AL only has one date format for hard coded dates of YYYY-MM-DD.Ā  So a value in your code like this 100518D (for today) must to be changed to 20181015D in AL.

      This article spekas to some of the differences in AL and C/AL: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-differences

      ——————————
      Jason Wilder
      Senior Application Developer
      Stonewall Kitchen
      York ME
      ——————————
      ——————————————-

    Jason Wilder replied 7 years, 9 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Learning proper AL formatting’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!