Dynamics 365 Business Central: Best Practices for AL File naming

Dynamics 365 Business Central

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 objectsExtensions
<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:

ObjectAbbreviation
PagePage
Page ExtensionPageExt
Page CustomizationPageCust
CodeunitCodeunit
TableTable
Table ExtensionTableExt
XML PortXmlport
ReportReport
Request PageRequestPage
QueryQuery
EnumEnum
Enum ExtensionEnumExt
Control Add-insControlAddin
DotnetDotnet
ProfileProfile
InterfaceInterface
Permission SetPermissionSet
Permission Set ExtensionPermissionSetExt

File naming examples:
For the listed objects in the table, these examples show how to name the files.

Object nameFile name
codeunit 70000000 MyPrefixSalespersonMyPrefixSalesperson.Codeunit.al
page 70000000 MyPrefixSalespersonMyPrefixSalesperson.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 objectsExtensions
<type><ID>.<ObjectName>.al<type><BaseId>-Ext<ObjectID>.<ObjectName>.al

Old File naming examples:

Object NameFile Name
table 70000000 MyPrefixSalespersonTab70000000.MyPrefixSalesperson.al
page 70000000 MyPrefixSalespersonPag70000000.MyPrefixSalesperson.al
page 70000000 MyPrefixSalesperson extends "Customer Card"Pag21-Ext70000000.MyPrefixSalesperson.al

Old Type map:

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL