Build a maintainable Business Central extension

Completed

You already have Visual Studio Code, the AL Language extension, and a sandbox connection configured. This unit assumes that environment is in place and focuses on the objects and manifest settings you change when you complete or extend an AL project.

Choose the right object type for the change

An AL extension never edits base application or another extension's source code directly. Instead, you add new objects or extend existing ones with objects designed for that purpose:

  • A table extension or page extension adds fields, actions, or triggers to an object you don't own, without duplicating its definition.
  • A new table, page, codeunit, report, or enum introduces behavior or storage that doesn't already exist anywhere else in the base application or another extension.
  • A new enum extension adds values to an enum type that another extension or the base application defines.

For example, a table extension adds a field to the standard Customer table without changing the original object:

tableextension 50100 "Contoso Customer Ext" extends Customer
{
    fields
    {
        field(50100; "Contoso Risk Rating"; Enum "Contoso Risk Rating")
        {
            Caption = 'Risk rating';
            DataClassification = CustomerContent;
        }
    }
}

The corresponding page extension surfaces that field where users already work with customer records:

pageextension 50101 "Contoso Customer Card Ext" extends "Customer Card"
{
    layout
    {
        addafter("Credit Limit (LCY)")
        {
            field("Contoso Risk Rating"; Rec."Contoso Risk Rating")
            {
                ApplicationArea = All;
                Caption = 'Risk rating';
            }
        }
    }
}

Choosing the extension object over duplicating the base table or page keeps the change small, upgrade-safe, and easy to review. Reserve new tables and codeunits for genuinely new storage or logic that doesn't belong on an object you're already extending.

Keep manifest identity, versioning, and dependencies accurate

The app.json manifest identifies your extension and declares what it depends on. Every field in this file has a specific role, and getting one wrong causes a compile or publish failure rather than a silently wrong result:

{
  "id": "3f6e9c21-8a4d-4b7e-9c31-2d4f5a6b7c80",
  "name": "Contoso Risk Management",
  "publisher": "Contoso",
  "version": "1.2.0.0",
  "application": "27.0.0.0",
  "idRanges": [{ "from": 50100, "to": 50149 }],
  "dependencies": [],
  "runtime": "16.0"
}
  • id is a globally unique identifier that never changes after you publish the extension. Changing it creates a different extension in the eyes of the platform, not a new version of the same one.
  • version follows a four-part number. Raise it whenever you change behavior that other extensions or the base application might depend on, so dependents can require a version that includes your fix.
  • application declares the minimum Business Central application version your extension targets, including its Base Application and System Application reference. Don't add explicit dependencies for those Microsoft applications. Publishing to an older application version than this value fails.
  • idRanges reserves the object IDs your extension is allowed to use. Two extensions with overlapping ranges can still coexist as long as neither one actually declares an object ID inside the overlap, but a shared team convention avoids the risk entirely.
  • dependencies lists other extensions your project references, each identified by id, name, publisher, and a minimum version. The example has no dependency on another independently installed extension. If your project is one project in a multi-root workspace, the dependency entry must match the referenced project's own manifest exactly, or the project reference doesn't resolve.

Use namespaces and access modifiers to keep boundaries clear

When your workspace contains more than one project, or when other partners might extend your extension later, namespaces and access modifiers keep object names and internal logic from leaking across boundaries you don't intend to expose:

namespace Contoso.RiskManagement;

codeunit 50102 "Risk Rating Calculator"
{
    Access = Public;

    procedure CalculateRating(DaysOverdue: Integer): Enum "Contoso Risk Rating"
    begin
        if DaysOverdue <= 0 then
            exit("Contoso Risk Rating"::Low);
        if DaysOverdue <= 30 then
            exit("Contoso Risk Rating"::Medium);
        exit("Contoso Risk Rating"::High);
    end;
}

The default object access is Public, so explicitly set Access = Internal on tables, codeunits, and queries that another extension shouldn't reference. Keep Access = Public only on objects that form the supported API. Procedures are public by default within an accessible object. Mark a procedure internal when only the same module should call it, or local when only its declaring object should call it. These modifiers control compile-time visibility, not runtime security.

Compile, package, and check maintainability before you move on

Building the project (Ctrl+Shift+B) compiles your AL code against the symbols for your declared dependencies and produces the .app package file you publish later. Before you consider a change complete, confirm that:

  • The build produces no compiler errors, and any analyzer warnings are ones your team's ruleset intentionally allows.
  • Every new or changed object uses an ID inside your declared idRanges, and every dependency entry matches its target's actual manifest values.
  • Public objects and procedures have a clear, narrow purpose, and nothing that should stay internal is marked Public by oversight.

A change that passes these checks is easier to translate, debug, and deploy in the units that follow, because the object boundaries and manifest values it introduces are exactly what the rest of the lifecycle depends on.

For the complete extension model and supported object types, see Development in AL and Extension objects overview.