AL is the programming language that is used for manipulating data (such as retrieving, inserting, and modifying records) in a Microsoft Dynamics 365 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 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. Also, we can combine data from multiple tables into one report or display it on one page.

Where to write AL code

Almost every object in Microsoft Dynamics 365 Business Central contains triggers where you can add your AL code. Triggers exist for the following objects: Tables and table extensions, Table fields, Pages and page extensions, Reports, Data items, XML ports and Queries. You can also initiate the execution of your AL code from Actions too. Any object that has an instantiation of the object that contains AL code. An example of an instantiation is a variable declaration.

Guidelines for placing AL code

The following guidelines for AL code in Microsoft Dynamics 365 Business Central database are recommended. In general, write 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 run 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

Reusing code makes developing applications both faster and easier. More importantly, if you organize the AL code as suggested in Microsoft Dynamics 365 Business Central database, the applications developed 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.

SIROCo offers customized support for Microsoft Dynamics 365 Business Central with following unique services like combining disconnected systems into one comprehensive solution, connecting systems and processes for efficient finance, sales, service and operations management, implementing embedded applications, including banking, CRM, or customer APIs, extension and expanding solutions (through Microsoft AppSource) to meet industry or business needs, built-in business productivity and intelligence with integration to Microsoft Dynamics 365 Business Central and Microsoft Power BI and securing the future with this enterprise-tested cloud solution.