AL is the programming language that is used for manipulating data (such as retrieving, inserting and modifying records) in a Dynamics 365 for Finance and Operations, Business edition database, and controlling the execution of the various application objects, such as pages, reports, or codeunits.
With AL, you can create business rules to ensure that the data which is stored in the database is meaningful and consistent with the way customers do business. Through AL programming, you can:
•Add new data or transfer data from one table to another, for example, from a journal table to a ledger table.
•Combine data from multiple tables into one report or display it on one form or page.
Where to write AL code
Almost every object in Dynamics 365 for Finance and Operations, Business edition contains triggers where you can add your AL code. Triggers exist for the following objects:
You can initiate the execution of your AL code from the following:
•Any object that has an instantiation of the object that contains AL code. An example of an instantiation is a variable declaration.
Note:If the AL code is in a local method, then you cannot run it from another object.
Guidelines for placing AL code
We recommend the following guidelines for AL code:
•In general, put the code in codeunits instead of on the object on which it operates. This promotes a clean design and provides the ability to reuse code. It also helps enforce security. For example, typically users do not have direct access to tables that contain sensitive data, such as the General Ledger Entry table, nor do they have permission to modify objects. If you put the code that operates on the general ledger in a codeunit, give the codeunit access to the table, and give the user permission to execute the codeunit, then you will not compromise the security of the table and the user will be able to access the table.
•If you must put code on an object instead of in a codeunit, then put the code as close as possible to the object on which it operates. For example, put code that modifies records in the triggers of the table fields.
Reusing code makes developing applications both faster and easier. More importantly, if you organize your AL code as suggested, your applications will be less prone to errors. By centralizing the code, you will not unintentionally create inconsistencies by performing the same calculation in many places, for example, in several triggers that have the same table field as their source expression. If you have to change the code, you could either forget about some of these triggers or make a mistake when you modify one of them.
Getting Started with AL…
Steps to set up a sandbox environment and Visual Studio Code
Go through the following steps to set up a sandbox environment. With the preview you get sample code that compiles and runs with just a few commands.+
1) Sign up for a Dynamics 365 for Financials sandbox.
2) Download Visual Studio Code.
3) Download the AL Language extension.
4) Press Alt+A, Alt+L to trigger the Go! command, and then choose Cloud.
5) Enter the credentials you provided for the sign up, and then Download symbols.
6) Press F5 to deploy and run the extension on your online sandbox tenant. +
Use Ctrl+Shift+P to clear the credentials cache if you want to deploy against a different environment.+
You now have a HelloWorld sample that compiles and runs. The JSON files in the project are automatically updated with the settings that allows you to press F5 to build and deploy the solution.+
If symbols are missing, you will be prompted to download them.+
As this feature is still in preview you might run into unrecoverable issues from time to time. In these cases, use Reset Sandbox to reset the sandbox and start from a clean environment.+
Interested in an on-premise version? It’s just as easy. Just sign up by following these steps.+
1) First, you will need an Azure subscription, sign up for a free subscription.
2) Go to the Developer Preview.
3) When you have a virtual machine set up, you will see a welcome text and here you can choose to try out the developer preview following the instructions on the screen. +
Build and get inspired by our sample library on GitHub.+
JSON file settings
There are two JSON files in the project; the
app.json file and the
launch.json file. The files are automatically generated for your project. For more information, see JSON files.+
The symbol file
The symbol file contains metadata of the application. This is what your extension is being built on, and therefore the symbol file must be present. If it is not present, you will be prompted to download it. For more information about the platform symbol file, see Symbols.+
Installing and publishing an extension
To make your extension available to users, the package must be published to a specific Microsoft Dynamics NAV Server instance. The extension can be installed for one or more tenants. For more information about how to install and publish an extension, see How to: Publish and Install an Extension V2.
AL Development Environment…(Samples) – (GitHub).