Many of us are still running our apps without namespaces, but it’s time to embrace namespaces in AL. Check out this video for the procedure of adding a namespace to an app.

In this video, Erik walks through the practical steps of adding namespaces to an existing Business Central app. After initially being in the “haven’t bothered with namespaces” camp for a couple of years, he explains why now is the time to start — and demonstrates the entire process from configuring the namespace template to fixing all the compilation errors that follow.
Why Consider Namespaces Now?
When namespaces were first introduced for AL, Erik — like many developers — didn’t rush to adopt them. There were no negative consequences to skipping them, and everything worked fine without them. But that’s starting to change. Microsoft now surfaces a default warning in the AL Language extension:
“Use namespace to organize your code and isolate it from changes.”
While Erik quips that he’s “not sure what changes we’re isolating it from,” the signal is clear: namespaces are becoming an expected part of AL development, and it’s time to get on board.
Setting Up the Namespace Template
The first step is configuring the namespace template in VS Code settings. This is important: you want to set this at the workspace level, not globally.
- Open Settings in VS Code
- Switch to the Workspace tab
- Search for the AL Language extension settings
- Find “Namespace template” — this specifies the default namespace to be used when creating new files or adding namespaces via code actions
Choosing a Namespace Convention
Erik looks at how Microsoft structures their own namespaces for guidance. For example, the GL Account table lives in:
Microsoft.Finance.GeneralLedger.Account
The pattern follows a hierarchy from most significant to least significant:
Company.Module.Area.SubArea
For his Certify integration app, Erik settles on:
Hogarth.Apps.Certify
The reasoning is straightforward: “Hogarth” is the brand, “Apps” represents the product line, and “Certify” is the specific app. With around 14–15 apps under the brand, there’s no need for additional grouping at this level. However, for more complex apps like a toolbox with sub-modules (AL compiler, symbol management, etc.), you might add deeper nesting.
Applying Namespaces to All Files
With the template configured, the quick fix light bulb now offers new options:
- Add namespace from template — fix this instance only
- Add namespace from template — fix all in document
- Add namespace from template — fix all in project
- Add namespace from template — fix all in workspace
Selecting “fix all in project” adds the namespace declaration to every file in one shot.
Updating the Runtime Version
After applying namespaces, you’ll likely see this error:
“Namespace support is not available in runtime version 9. The supported runtime versions are 12 or greater.”
This means you need to update your app.json. Here’s what a pre-namespace app.json might look like:
{
"id": "56158416-cadb-42da-a963-77ad9482cde9",
"name": "namespaces",
"publisher": "Default publisher",
"version": "1.0.0.0",
"brief": "",
"description": "",
"privacyStatement": "",
"EULA": "",
"help": "",
"url": "",
"logo": "",
"dependencies": [],
"screenshots": [],
"platform": "1.0.0.0",
"application": "21.0.0.0",
"idRanges": [
{
"from": 50100,
"to": 50149
}
],
"resourceExposurePolicy": {
"allowDebugging": true,
"allowDownloadingSource": true,
"includeSourceInSymbolFile": true
},
"runtime": "10.0",
"features": [
"NoImplicitWith"
]
}
The runtime needs to be bumped to at least 12.0, which corresponds to Business Central version 23. Erik’s general philosophy on runtime versioning is to use the lowest version that supports what you need — this maximizes compatibility with on-premise customers who may be stuck on older versions like BC 22 or 24. But namespaces require runtime 12 as the minimum, so that becomes the new floor.
After updating the runtime (and corresponding application/platform versions), the namespace declarations start working.
Fixing Missing Using Statements
Adding namespaces to every file is only half the battle. Once namespaces are enabled, any reference to objects from other namespaces needs to be resolved. You’ll see errors like:
“The name ‘General Journal Line’ does not exist in the current context.”
The quick fix offers two approaches:
Option 1: Fully Qualify
This inlines the full namespace path directly in the code:
Microsoft.Finance.GeneralLedger.Journal.GeneralJournalLine
There’s no ambiguity about what “General Journal Line” refers to, but it’s verbose.
Option 2: Add Using Statement
This adds a using directive at the top of the file, allowing you to reference the object by its short name:
using Microsoft.Finance.GeneralLedger.Journal;
Erik prefers the using approach as it’s cleaner. And critically, you can apply it across the entire project at once by selecting “Add all missing using statements in project.”
You may need to run this fix multiple times. After the first pass resolves most issues, a recompile (Shift+Ctrl+B) may reveal additional missing references — for example, references to Bank Account or Extension Settings pages that live in different namespaces. Each round of “add all missing using statements in project” chips away at the remaining errors until you reach zero.
A Note on Compilation Sync
Erik points out that there are effectively two compilations happening: the background AL engine that populates the Problems panel, and the explicit build triggered by Shift+Ctrl+B. These can get out of sync, especially during large-scale changes like adding namespaces to an entire project. If things look odd, trigger a manual build to get an accurate picture.
Sub-Namespaces for Larger Apps
For a simple app, a single namespace like Hogarth.Apps.Certify works well. But for larger apps, you might want to organize objects into sub-namespaces. For example, credit card–related objects could live in:
Hogarth.Apps.Certify.CreditCard
This kind of organization has to be done manually — the automation can’t figure out which objects belong in which sub-namespace. Changing an object’s namespace may also require adding new using statements elsewhere in the project.
Order Matters for Multi-App Dependencies
If you have multiple apps that depend on each other, you need to add namespaces in the correct order. Start with the apps that are consumed by others (your base/foundation apps), then work up the dependency chain. This ensures that when you add using statements in dependent apps, the referenced namespaces already exist.
A Simple Example
Here’s what a basic AL file looks like after adding a namespace:
namespace Hogarth.Apps.Certify;
codeunit 50139 "Helper Functions"
{
procedure Helpful()
begin
Message('You are wonderful, have a nice day!');
end;
}
The namespace declaration is the very first line of the file, before any object definitions.
Summary
Adding namespaces to an existing Business Central app is more straightforward than you might expect, thanks to the code action quick fixes in the AL Language extension. The key steps are:
- Configure the namespace template in your workspace settings
- Apply the namespace to all files using “fix all in project”
- Update the runtime to 12.0 or higher in
app.json - Fix missing using statements across the project (possibly multiple passes)
- Optionally organize objects into sub-namespaces for larger apps
- Process apps in dependency order if you have multiple related apps
The tooling does most of the heavy lifting. The main decisions you need to make are what to name your namespaces and whether any objects deserve their own sub-namespace. With Microsoft increasingly expecting namespaces in AL code, now is a good time to make the switch.