Microsoft AL Language

repository·master·Indexed 21 days ago

https://github.com/microsoft/al

Tracking hub for issues related to the AL compiler and developer tools used in the Visual Studio Code AL Language extension for Microsoft Dynamics 365 Business Central. Includes the highlightjs-al syntax highlighting plugin and samples for Control Add-ins.

Tokens
852
Snippets
3
Records
6
Agent score
75%

What's inside AL

  1. Install the AL Language extension for Visual Studio Code

    master

    To develop extensions for Microsoft Dynamics 365 Business Central, install the AL Language extension from the Visual Studio Code Marketplace. This extension provides the AL compiler and developer tools required for extension development.

    Marketplace Link: ms-dynamics-smb.al

  2. Get started with AL development

    master

    For comprehensive guides on using the AL Language to extend Dynamics 365 Business Central, refer to the following official Microsoft documentation topics:

    • Getting Started: Link
    • Building Your First Sample Extension: Link
    • Developer Reference: Link
  3. Implement the CallJavaScript entrypoint for Control Add-ins

    master

    When building a Control Add-in for Business Central, you can define a JavaScript function that is callable from AL code. The CallJavaScript function in this example acts as an entrypoint that receives data passed from the AL side and updates the DOM.

    To use this pattern, ensure your JavaScript file is included in your Control Add-in setup and that the function name matches the call made in your AL code.

    function CallJavaScript(i, s, d, c) {    
        var div = document.querySelectorAll(".cb")[0];
        div.innerText = ['Received from AL:', i, s, d, c].join(' ');
    }
  4. Update HighCharts data via LoadData function

    master

    In a Control Add-in implementation using HighCharts, you can define a LoadData(data) function to receive data from the AL environment. This function iterates over the incoming array and updates the first series of the HighCharts instance using setData. The expected input format for data is an array of objects where each object contains a code and a value property.

    function LoadData(data) {
        chart.series[0].setData(data.map(x => [x.code, x.value]));
    }
  5. Register the AL language definition for highlight.js

    master

    The highlightjs-al package provides a language definition for Microsoft Dynamics 365 Business Central's AL language. It is exported as a default function that accepts a hljs (highlight.js) instance and returns a language configuration object. This configuration includes support for AL keywords, built-in types, metadata, strings, numbers, dates, and various object definitions (with and without IDs).

    import hljs from 'highlight.js';
    import alLanguage from 'highlightjs-al';
    
    hljs.registerLanguage('al', alLanguage);
    // or
    hljs.registerLanguage('AL', alLanguage);