Dynamics 365 Business Central AL Programming - Locus IT Services

Dynamics 365 Business Central AL Programming

Locus IT ServicesMicrosoft Dynamics 365 / D365Dynamics 365 Business Central AL Programming

Dynamics 365 Business Central AL Programming

Dynamics 365 Business Central AL Programming language is utilized for manipulating data (such as retrieving, inserting and modifying records) in a MS D365 Business Central database and controlling the execution of the various application objects, such as pages, reports or code units.

With AL, you can create business rules to ensure that the data which is stored in the database is meaningful and compatible with the way customers do business. Using AL programming, you can:

  • Insert 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.

Dynamics 365 Business Central AL Programming Process

1. Where to Write AL Code

Almost every object in Dynamics 365 Business Central contains triggers where you can add your AL code. Triggers exist for the following objects:

  • Tables
  • Table fields
  • Pages
  • Reports
  • Data items
  • XMLports
  • Queries

You can initiate the execution of your AL code from the following:

  • Actions
  • Any object that has an instantiation of the object that contains AL language code. An example of an instantiation is a variable declaration.

2. 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 encourages a clean design and provides the ability to reuse code. It also helps enforce security. For example, typically users will not possess direct access to tables that consist of the sensitive data, such as the General Ledger Entry table or do they have permission to modify objects.
  • If you place the code that operates on the general ledger in a code unit, give the code unit access to the table and give the user permission to execute the code unit, then the security of the table will not compromised and the user will be able to utilize the table.
  • If you must put code on an object instead of in a code unit, then place the code as close as possible to the object on which it executes. For example, put code that modifies records in the triggers of the table fields.

3. Reusing Code

Reusing code makes developing applications both faster and easier. Importantly, if you arrange the AL code as recommended, the applications will be less vulnerable to errors.

By centralizing the code, you will not involuntarily create inconsistencies by doing the similar calculation in different places, for example, in many triggers that have the similar table field as their source expression.

If you have to change the code, you could either neglect about some of these triggers or make a mistake when you alter one of them. For more information on Microsoft Dynamics 365 Business Central AL Programming, please contact us.

Locus IT Project Management Office
What’s it?