AL language code sample in Visual Studio for developing extensions for Dynamics NAV - CloudFronts

AL language code sample in Visual Studio for developing extensions for Dynamics NAV

Microsoft has released AL language code samples for developing extensions for Dynamics NAV.  This AL sample code is available to download from the following link: https://github.com/Microsoft/AL. Microsoft wants to move all development very soon to Visual Studio using AL code for Dynamics NAV and Dynamics 365 Financials. Hence, programming for developing extensions for Dynamics NAV and Dynamics 365 have to be done in Visual Studio in the future.

This article explains about the AL sample code for developing extensions for Dynamics NAV in Visual Studio.

Prerequisite:

Visual Studio

Purpose:

To understand AL language code sample for developing extensions for Dynamics NAV in Visual Studio.

Explanation:

  1. The new version of extensions will be called ‘Extensions 2.0’ which is not based on the Delta file design. With Extensions 2.0, developers need to code and write new objects that describe additional capabilities required in the system. ‘Table Extension’ and ‘Page Extension’ objects will be used to describe new fields and UI elements and ‘in-client page designer’ will be used to make those changes in a WYSIWIG way-all of which are stored as extensions under the cover.

    This is referred from the following link:

    https://blogs.msdn.microsoft.com/nav/2016/12/13/more-information-about-the-developer-preview-for-dynamics-nav/

  2. In the AL sample code released by Microsoft, there are three .al files i.e. HelloWorld.al, GreetingsManagement.al and CustomerCardExtension.al and two .json files i.e. launch.json and app.json.
  3. CustomerCardExtension.al and HelloWorld.al are adding an action on Customer Card page. CustomerCardExtension.al is a ‘pageextension’ object type. The RunObject property of CustomerCardExtension.al calls HelloWorld.al which is a codeunit object.


    Fig. 1: CustomerCardExtension.al calls the Codeunit HelloWorld.al

    The keyword extends tells the compiler that this object is extending an existing object that is named after.

  4. On clicking this new action which is created on Customer Card page, Codeunit GreetingsManagement.al runs and generates a greeting message. GreetingsManagement.al is a codeunit for creating random greetings.


    Fig. 2: Codeunit GreetingsManagment.al

  5. While creating extensions in the previous way, manifest file has to be generated using Windows PowerShell ISE which is done after creating delta files. But while using AL code for developing extensions for Dynamics NAV in Visual Studio, ‘app.json’ file is required. ‘app.json’ is a manifest file that defines how your code should be built and bootstrapped into a live application. It enables developers to define their applications’ details, setup configurations and runtime environments in a structured way.


    Fig. 3: app.json

  6. To debug your app in VS Code, it is needed to set up launch configuration file which is ‘launch.json’.

  7. Fig. 4: launch.json

    Conclusion:

    The Visual Studio Code editor will become the preferred way of doing modifications in the future and all extensions for Dynamics NAV will be done in Visual Studio. Microsoft has mentioned that in the future, they will be adding support for XML Ports, Queries and Reports in Visual Studio Code.

     


Share Story :

Secured By miniOrange