Hi, Readers.
Today I would like to share some information on best practices for AL File naming.
AL is the programming language that is used for manipulating data such as retrieving, inserting, and modifying records in a Dynamics 365 Business Central database. It controls the execution of the various application objects, such as pages, reports, or codeunits. All AL Codes are written in AL files, so before adding AL Codes, we must first create AL files.
As you might know, all file systems follow the same general naming conventions for an individual file: a base file name and an optional extension, separated by a period. For AL file, the filename is FileName.al.
Here are the best practices suggested by Microsoft.
File naming notation:
Follow the syntax for file naming as shown in the table:
Full objects | Extensions |
---|---|
<ObjectNameSuffix>.<FullTypeName>.al | <ObjectNameSuffix>.<FullTypeName>Ext.al |
<PrefixObjectName>.<FullTypeName>.al | <PrefixObjectName>.<FullTypeName>Ext.al |
<ObjectNameExcludingAffix>.<FullTypeName>.al | <ObjectNameExcludingAffix>.<FullTypeName>Ext.al |
Type map:
Use the listed abbreviations for each type of object in the file naming:
Object | Abbreviation |
---|---|
Page | Page |
Page Extension | PageExt |
Page Customization | PageCust |
Codeunit | Codeunit |
Table | Table |
Table Extension | TableExt |
XML Port | Xmlport |
Report | Report |
Request Page | RequestPage |
Query | Query |
Enum | Enum |
Enum Extension | EnumExt |
Control Add-ins | ControlAddin |
Dotnet | Dotnet |
Profile | Profile |
Interface | Interface |
Permission Set | PermissionSet |
Permission Set Extension | PermissionSetExt |
File naming examples:
For the listed objects in the table, these examples show how to name the files.
Object name | File name |
---|---|
codeunit 70000000 MyPrefixSalesperson | MyPrefixSalesperson.Codeunit.al |
page 70000000 MyPrefixSalesperson | MyPrefixSalesperson.Page.al |
pageextension 70000000 MyPrefixSalesperson extends “Customer Card” | MyPrefixSalesperson.PageExt.al |
Let’s look at a few specific examples.
table 21 “Cust. Ledger Entry” -> CustLedgerEntry.Table.al
page 21 “Customer Card” -> CustomerCard.Page.al
report 1306 “Standard Sales – Invoice” -> StandardSalesInvoice.Report.al
pageextension 9206 “User Personalization” extends “User Personalization” -> UserPersonalization.PageExt.al
So each file name has object names with only characters [A-Za-z0-9], object type, and dot al, for file type. In your extension, the name of each new application object (table, page, codeunit), can contain a prefix or suffix.
The CodeCop analyzer suggests that the object name is part of the file name, which is encouraged as a best practice. Adding any affixes to the file names is voluntary.
The file DocumentAttachmentDetails.al has an incorrect name. The valid name is RenameDialog.Page.al.
PS:
1. The file name can be changed at any time and this is not a breaking change.
2. In addition to file names, you can also create folders to manage AL files, Microsoft base application is categorized by function, you can also create folders based on object types, there is no restriction on this.
3. If you are submitting an app to AppSource, you must follow the guidance in the Technical Validation Checklist.
4. Benefits and guidelines for using a prefix or suffix
5. How to easily export all AL file names and Object Details (Type, ID, Name)
6. You can find more about Best Practices for AL in MS Learn (Docs)
7. You can use waldo’s CRS AL Language Extension to change all file names at once.
For example,
"CRS.FileNamePattern": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al"
The last thing I want to share is that these best practices has actually changed in the past, it wasn’t in this format before. (Of course it is no longer recommended)
Old File naming notation:
Full objects | Extensions |
---|---|
<type><ID>.<ObjectName>.al | <type><BaseId>-Ext<ObjectID>.<ObjectName>.al |
Old File naming examples:
Object Name | File Name |
---|---|
table 70000000 MyPrefixSalesperson | Tab70000000.MyPrefixSalesperson.al |
page 70000000 MyPrefixSalesperson | Pag70000000.MyPrefixSalesperson.al |
page 70000000 MyPrefixSalesperson extends "Customer Card" | Pag21-Ext70000000.MyPrefixSalesperson.al |
Old Type map:
END
Hope this will help.
Thanks for reading.
ZHU
コメント