AL code
AL code best practices for Business Central extensions: naming conventions, file structure, formatting, deprecation with obsolete attributes and CLEAN symbols, prefix and suffix rules, and rules that cause app validation failures. It answers questions about how to write, name, and retire AL code so it passes Marketplace submission.
Path: Development > Rules, guidelines, and best practices > Best practices > AL code · tier official · system development · narrative unreviewed (model text not yet checked)
Overview
This section collects the guidance for writing AL code in Business Central extensions. It has four pages and no subtopics. They cover general coding conventions, how to deprecate code, how to name objects with a prefix or suffix, and the rules that app validation enforces.
Start with “Best practices for AL code” for file naming, object naming, method declaration, variable naming, formatting, and line length. Then read “Prefix and suffix for naming in extensions” to see why an affix is needed to prevent name collisions and how it ties to Marketplace standards, affix registration, and AppSourceCop.
Use “Rules and guidelines for AL code” before you submit an app. It lists critical errors, important errors, and 14 common pitfalls behind validation failures. Use “Best Practices for Deprecation of AL Code” when you retire objects or members. It explains how Microsoft obsoletes code in the Base App, and you can follow the same pattern.
Key points
- General conventions cover file naming, object naming, method declaration, variable naming, code formatting, and line length.
- A prefix or suffix on extension object names prevents name collisions and is part of the Marketplace submission standards.
- The affix page covers affix registration, namespaces, and the AppSourceCop check.
- The rules page separates critical errors (encryption key function restrictions, sensitive data protection) from important errors.
- 14 common pitfalls that cause app validation failures are listed, including prefix/suffix requirements, data classification, translation files, and permission sets.
- Deprecation uses preprocessor directives and the ObsoleteState, ObsoleteTag, and ObsoleteReason properties.
- The deprecation page describes CLEAN version symbols (CLEAN15 to CLEAN18) as the pattern Microsoft uses in the Base App.
Learn pages
- Best practices for AL code: Best practices for writing AL code for Business Central.
- Best Practices for Deprecation of AL Code: Description of best practices and guidelines for deprecating code in the Base App for Business Central.
- Prefix and suffix for naming in extensions: Use a prefix or suffix for names in your extension. This rule applies to all objects, including tables, pages, and codeunits. This topic explains the benefits and guidelines for using a prefix or suffix.”
- Rules and guidelines for AL code: Describing the steps you must go through to successfully submit your Dynamics 365 Business Central app to Marketplace.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #11609 [Main]-Reduce redundant record restriction checks in item journal line (code change): “Record restriction checks in item journal operations are optimized”
- #11682 [Expense Agent] Remove migration TODO and analyzer suppressions (code change): “Replaced broad AA0073 suppression with compliant temporary-record variable names”
- #12078 [29.x]Reduce allocations in the “Export to Execl” scenario (#11870) (code change): “Reuses the default CellDecorator instead of creating new instances for each column-row combination”
- #9700 Rename TempCustomMigrationTableBuffer back to CustomMigrationTableBuffer (code change): “Removes the Temp prefix that violated AA0237 on a non-temporary variable”
- #105 Promote validated community knowledge (code change): “Community AL best practice articles are promoted to Microsoft-endorsed knowledge”
- #128 knowledge: improve review precision from BCApps PR 10080 feedback (code change): “Two knowledge articles revised after maintainers gave thumbs-down feedback”
- #136 Add community knowledge: AL boolean operators do not short-circuit (code change): “AL boolean operators do not short-circuit”
- #147 ShowMandatory + OnQueryClosePage Check (code change): “Two new UI community knowledge articles with code examples demonstrate best practices”
- #161 AL methods limited during write transactions (RunModal, Codeunit.Run) (code change): “Recommended structure follows Base Application’s Commit before Page.RunModal pattern”
- #193 Clarify locale-safe DateFormula Evaluate inputs (code change): “Clarify locale-safe DateFormula Evaluate inputs. Adds a Microsoft Style article”
- #198 Add BC performance knowledge from OptimAL learnings (code change): “Each new article has paired good and bad AL examples”
- #225 Performance and style knowledge: compute Role Center headlines in the background; build client links with GetUrl (code change): “links into the running environment’s client should come from GetUrl”
- #227 Evaluation: keep sample comments for the two articles whose rule is about comments (code change): “articles about comments themselves retain full-line comments in samples”
- #228 Knowledge: isolated events, FilterGroup scope, BLOB CalcFields and stream text encoding (code change): “paired good and bad code examples”
- #249 Route guard-dependent and/or conditions to the short-circuit article (code change): “AL performance review skill gains a targeted cue to worklist the boolean-operators-do-not-short-circuit article”
- #251 Clarify 20-character limit for assignable permission set names (code change): “Assignable permission sets have a 20-character name limit, not the general 30-character limit”
- #273 knowledge(style): SetFilter date operands as replacement values; product name via ProductName (code change): “SetFilter rule prevents date text parsing issues by requiring date operands”
- #65 Add data-modeling and appsource knowledge articles (MICROSOFT layer) (code change): “Seven remedial BCQuality knowledge articles added to the MICROSOFT layer covering data-modeling patterns, AppSource conventions, and styling best practices”
- #95 style-review: calibrate analyzer-redundant rules to info; keep correctness bugs out of style scope (code change): “al-style-review skill recalibrates analyzer-redundant rules to info severity and clarifies domain boundaries”
- Business Central 29: The New IsDirty() Flag — Finally a Smarter Way to Detect Record Changes (community post): “Makes code cleaner and easier to maintain by eliminating boilerplate dirty-flag logic”
- Weekly Review: Business Central AL Development – June 21–27, 2026 (community post): “Moving older AL apps to namespaces improves object clarity, reduces naming friction”
- How to write good tooltips as a BC developer (community post): “following patterns like starting with Specifies”
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.