MSBA-352 · Lesson 2 of 12 · 20 min

Extensions and app.json

▶ Video coming soon A video version of this lesson is on the way.

With the workbench running, Noor asked Joss to throw away the Hello World sample and start the real project properly. "Most of what goes wrong with an extension in its second year was decided in the first hour," she said. "The name, the publisher, the ID range, the version, what it depends on. Get the manifest right and the rest is easier." This lesson covers that first hour: the app.json manifest, how an extension is identified and versioned, its object types and ID ranges, naming, namespaces, dependencies, and what happens when an extension is published, installed, upgraded and removed.

The manifest

Every AL project has one app.json file at its root. It is the extension's identity card. The compiler reads it to know what to build, Business Central reads it to decide whether the app can be installed, and administrators see its name, publisher and version on the Extension Management page.

The warranty extension's app.json. The id is a GUID generated once and never changed.
{
  "id": "6f1c2d4e-8a3b-4c57-9e21-0b7d5a9c3e18",
  "name": "Corbel & Finch Warranty",
  "publisher": "Quarrystone Business Systems",
  "version": "1.0.0.0",
  "brief": "Equipment warranty registrations and claims",
  "description": "Registers serial-numbered grinders and brewers when they ship, tracks warranty periods and logs claims.",
  "privacyStatement": "https://www.quarrystone.example/privacy",
  "EULA": "https://www.quarrystone.example/terms",
  "help": "https://www.quarrystone.example/help/cnf-warranty",
  "url": "https://www.quarrystone.example",
  "logo": "",
  "dependencies": [],
  "screenshots": [],
  "platform": "29.0.0.0",
  "application": "29.0.0.0",
  "idRanges": [
    { "from": 50100, "to": 50149 }
  ],
  "resourceExposurePolicy": {
    "allowDebugging": true,
    "allowDownloadingSource": true,
    "includeSourceInSymbolFile": true
  },
  "runtime": "18.0",
  "target": "Cloud",
  "features": [ "TranslationFile" ]
}
The app.json properties and the warranty project's choices.
PropertyWhat it doesJoss's value
idA GUID that identifies the app forever; upgrades match on itGenerated by AL: Go!, never edited
name, publisherShown to users; together with version they also identify a buildCorbel & Finch Warranty, Quarrystone Business Systems
versionMajor.minor.build.revision; an upgrade needs a higher version1.0.0.0
brief, description, privacyStatement, EULA, help, urlInformation shown on the extension's detailsQuarrystone's pages
platform, applicationMinimum versions of the platform and the Microsoft application apps29.0.0.0 (2026 release wave 2)
dependenciesOther apps this one needs, by id, name, publisher and minimum versionNone
idRangesThe object IDs this app may use50100 to 50149
resourceExposurePolicyWhether others may debug the app, download its source or see source in symbolsAll allowed, since the code belongs to Corbel & Finch
runtimeThe AL language version the compiler targets18.0
targetCloud restricts code to what Business Central online allowsCloud
featuresOptional compiler featuresTranslationFile, so captions can be translated

Noor spent most time on four of them.

The id. The GUID is the app's real identity. If someone copies a project folder to start a new extension and forgets to generate a new id, Business Central treats the two as the same app, and installing one replaces the other. Quarrystone's checklist for a new project starts with "new GUID".

The version. Business Central compares versions to decide whether a new .app is an upgrade. A version also tells support staff exactly which build a customer runs. Quarrystone increases the third number for every build that leaves a developer's machine and the minor number for every release to production, and records the version in the pull request.

The platform, application and runtime. These set the oldest Business Central the app can run on. Corbel & Finch runs version 29 in every environment, so the app targets 29 and runtime 18.0. A marketplace app aimed at many customers would set them lower, to reach tenants that have not yet updated, at the cost of newer language features.

The resource exposure policy. For a marketplace app, an ISV protects its intellectual property by refusing debugging and source download. For a per-tenant extension, the code belongs to the customer under the contract, so Noor allows all three. That lets another partner support Corbel & Finch one day without reverse engineering.

Object types

An extension is made of AL objects. Each object type has a keyword, and most take an ID and a name. The table lists the types this course uses and a few it only mentions.

AL object types.
Object typePurposeLesson
table, tableextensionStore data; add fields to standard tables3
page, pageextension, pagecustomizationShow data; add to standard pages; adjust pages for a profile4
codeunitHold procedures and event subscribers5, 6
report, reportextensionPrint, export or process data; add to standard reports7
queryRead joined, filtered and aggregated data efficiently8
enum, enumextensionDefine extensible lists of values9
interfaceDeclare procedures that codeunits implement9
permissionset, permissionsetextensionGrant access to objects and data10
profileDefine a role with its Role Centre and page customizations4
xmlportImport and export structured text or XML filesMentioned only
controladdinEmbed a JavaScript control in a pageMentioned only
entitlementTie permissions to licences for marketplace appsNext course

Object IDs and ranges

Every table, page, codeunit, report, query, enum and permission set has a numeric ID that must be unique within its type in the tenant. Microsoft reserves ranges for its own apps. The range 50,000 to 99,999 is set aside for per-tenant extensions, and Microsoft assigns separate, much higher ranges to marketplace publishers so that apps from different vendors never collide.

Because all PTEs share the same range, two per-tenant extensions from different partners in the same tenant could clash. Quarrystone keeps a register of the ranges it has allocated in each customer's tenant. Corbel & Finch has one other small Quarrystone extension, for the web shop integration, in 50000 to 50099; the warranty app gets 50100 to 50149, recorded in idRanges so that the compiler rejects any object outside it.

Table extensions and page extensions also take IDs from the range. Fields added by a table extension get field numbers from the range too, so the warranty fields on the Item table start at 50100.

Names, affixes and namespaces

Object names must also be unique, and a name like "Warranty Registration" could easily clash with another app or a future Microsoft object. The traditional answer is an affix: a short tag added to the start or end of every object name and every field or action added to a standard object. Marketplace publishers register their affixes with Microsoft. For per-tenant extensions an affix is good practice rather than a requirement, and Quarrystone uses CNF for Corbel & Finch. The new table is "CNF Warranty Registration", and the field added to the Item table is "CNF Warranty Period".

Namespaces add a second layer of organization. A namespace declaration at the top of a file places its objects under a dotted name, and using directives let the file refer to objects in other namespaces by their short names. Microsoft has moved the base application into namespaces such as Microsoft.Sales.Document for sales headers and lines and Microsoft.Inventory.Item for items. Quarrystone's convention is Company.Customer.App, so every warranty file starts with namespace Quarrystone.CorbelFinch.Warranty;.

A namespace and using directives at the top of an AL file.
namespace Quarrystone.CorbelFinch.Warranty;

using Microsoft.Inventory.Item;
using Microsoft.Sales.Customer;
using Microsoft.Sales.History;

codeunit 50100 "CNF Warranty Mgt."
{
    // Procedures arrive in lesson 5.
}

Namespaces do not replace the affix in Quarrystone's house style. They make code easier to navigate, and they help when two apps really do pick the same name, but users never see a namespace. They see captions, and a caption that starts "CNF" on a page full of standard fields tells an administrator exactly which app added it.

Dependencies

Every extension depends on Microsoft's apps, which app.json covers with the platform and application properties. The dependencies array lists anything else. If Quarrystone later builds a shared toolkit app used by several customers, the warranty app would list it with its id, name, publisher and minimum version, download its symbols, and use its objects as if they were standard ones.

Dependencies have consequences. Business Central will not install an app until its dependencies are installed, and will not uninstall a dependency while something still uses it. A dependency also ties two release schedules together. Noor's advice was to keep a per-tenant extension standalone unless the shared code is substantial, and the warranty app has an empty list.

A stack of layers from bottom to top: Platform, System Application, Business Foundation, Base Application, Application. On top sit two per-tenant extensions side by side: the web shop integration with IDs 50000 to 50099 and the warranty extension with IDs 50100 to 50149. Arrows labelled depends on point down from each extension to the Application layer.
Corbel & Finch's extensions sit on top of Microsoft's apps and depend only on them.

The extension lifecycle

An extension moves through distinct states, and each step does something different to the tenant.

From .app file to running extension and back.
StepWhat happens
PublishThe .app file is uploaded and its objects become known to the server
SynchronizeThe database schema is updated to match the app's tables and fields
InstallThe app is turned on for the tenant; install code runs
UpgradeA higher version replaces the installed one; upgrade code runs and data is kept
UninstallThe app is turned off; its data stays in the database by default
UnpublishThe app file is removed from the server

Publishing from Visual Studio Code does publish, synchronize and install in one step. In production the steps are visible: an administrator uploads the .app on the Extension Management page or schedules it from the admin centre, and Business Central installs it or upgrades the existing version.

Uninstalling does not delete data, which surprises many people. The tables stay, so reinstalling the app brings the registrations back. Deleting the data needs an explicit choice to delete extension data. Noor called this the most important safety net in the platform: "If someone uninstalls the warranty app by mistake in March, nothing is lost."

Schema changes and breaking changes

Once a table is installed with data, changes to it are restricted. Adding fields and keys is safe. Removing a field, changing its type to an incompatible one, shrinking a text field or changing the primary key are breaking changes: synchronization refuses them, because data would be lost. In a private container, the Recreate or ForceSync schema update mode in launch.json gets past this by dropping data. In production there is no such shortcut. The table or field must be marked obsolete first and its data moved by upgrade code, a process the next course covers.

For Joss, this meant designing tables carefully before the first build ever reached UPDATE-TEST, where Callum would enter test data. "Change your mind in the container as often as you like," Noor said. "Once Callum has typed in a hundred warranties, the design is a contract."

Install code

Some apps need data before anyone uses them: a setup record, default values, a number series. An install codeunit runs when the app is installed for the first time. Its triggers run once per database and once per company.

An install codeunit that creates a setup record in each company if it is missing.
namespace Quarrystone.CorbelFinch.Warranty;

codeunit 50101 "CNF Warranty Install"
{
    Subtype = Install;

    trigger OnInstallAppPerCompany()
    var
        WarrantySetup: Record "CNF Warranty Setup";
    begin
        if not WarrantySetup.Get() then begin
            WarrantySetup.Init();
            WarrantySetup."Claim Window Days" := 30;
            WarrantySetup.Insert();
        end;
    end;
}

The code checks before inserting, because install code can run again when an app is uninstalled and reinstalled. Code that assumes an empty table fails the second time. Upgrade codeunits, which run when a higher version replaces a lower one, follow the same defensive style and are covered in the next course with the rest of the deployment work.

Worked problem

Two apps with one GUID

A Quarrystone developer copied the warranty project to start a loyalty-card app for another customer, changed the name and publisher, and published it to a shared container. The warranty app disappeared from Extension Management. What happened, and what is the fix?

Show solution
  1. Business Central identifies apps by the id in app.json, not by name.
  2. The copied project kept the warranty app's GUID, so the server treated the loyalty app as a new version of the same app.
  3. Generate a new GUID for the loyalty project and publish it again.
  4. Republish the warranty app to restore it in the container.

Answer: Every new project needs its own GUID; the id, not the name, is the app's identity.

Captions and translations

Users never see object names such as "CNF Warranty Registration"; they see captions. Every table, field, page, action and report should have a Caption property, and every message a label (lesson 5). With the TranslationFile feature on in app.json, the compiler collects all captions, tooltips and labels into an XLIFF file in a Translations folder each time it builds. A translator, or a translation tool, produces a copy of that file for each language, and Business Central shows the right text for each user's language setting. Corbel & Finch works in English only, but Noor turned the feature on anyway. Adding French later would mean translating one file, not editing every object.

Common mistakes

  • MistakeReusing an existing project's app.json for a new app.

    InsteadGenerate a new GUID for every new app.

  • MistakePicking object IDs at random in the 50,000 to 99,999 range.

    InsteadAllocate a range per app per tenant, record it, and set idRanges so the compiler enforces it.

  • MistakeNaming objects without an affix.

    InsteadUse an affix such as CNF on objects and on fields and actions added to standard objects.

  • MistakeSetting the runtime as high as possible by default.

    InsteadSet it to match the oldest Business Central version the app must run on.

  • MistakeChanging a field type after the table has data in a shared sandbox.

    InsteadDesign tables carefully early; breaking changes need obsoleting and upgrade code.

Summary and key terms

  • app.json is the manifest: id, name, publisher, version, minimum versions, dependencies, ID ranges, exposure policy, runtime and target.
  • The GUID identifies the app; a higher version is needed for an upgrade.
  • Per-tenant extensions use IDs from 50,000 to 99,999, allocated per app and enforced with idRanges.
  • Affixes and namespaces prevent name clashes and make code easier to navigate.
  • Publish, synchronize, install, upgrade, uninstall and unpublish are separate steps; uninstalling keeps data.
  • Breaking schema changes are refused once a table has data; install code must be safe to run twice.
app.json
The manifest that identifies an extension and its requirements.
idRanges
The object ID ranges an app is allowed to use.
Affix
A short tag added to object, field and action names to avoid clashes.
Namespace
A dotted name that groups AL objects and lets files refer to them by short names.
Dependency
Another app that must be installed for this app to work.
Install codeunit
A codeunit with Subtype Install whose triggers run when the app is installed.
Breaking change
A schema change that would lose data, which synchronization refuses.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why does the warranty app allow debugging and source download when a marketplace app usually would not?

    Show answer

    The code belongs to Corbel & Finch as a per-tenant extension, so exposing it lets any future partner support it; ISVs protect their intellectual property instead.

  2. What happens to warranty registrations if the app is uninstalled?

    Show answer

    They stay in the database; uninstalling keeps data unless someone explicitly deletes the extension data.

  3. Why does the install codeunit check for the setup record before inserting it?

    Show answer

    Install code can run again after an uninstall and reinstall, and the record may already exist.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz