AL ID Sentinel
Collision-free AL object IDs for Business Central teams — and their AI agents.
The registry lives in your own Git repository. No server. No account. No configuration.
Two developers create a table at the same time. Both pick 50123. Nobody notices until the pipeline breaks — or worse, until
deployment. Now add GitHub Copilot, Claude Code and Codex creating objects on their own, and "just look at the last ID used"
stops working altogether.
AL ID Sentinel reserves every new AL object ID the moment you (or your agent) need it, in a small registry stored on a
dedicated branch of the repository you already have. Your Git credentials are the only thing it needs.
Why AL ID Sentinel
- 🛡️ Truly collision-free — every ID is reserved with a Git commit + push. If someone pushed first, it retries with the next free ID. No two people, no two agents, ever get the same number.
- 🤖 Built for AI agents — native GitHub Copilot tools (
#allocateObjectId, #allocateFieldId, #releaseObjectId) and a JSON CLI for Claude Code, Codex and scripts. Agents get a real, reserved ID instead of guessing one.
- 📦 Zero infrastructure — the registry is a Markdown file on an orphan branch of your repo. Nothing to host, no service to trust, no account to create. Any Git remote works: Azure Repos, GitHub, GitLab…
- 🌿 Branch-aware — it knows the IDs used on the remote branches you choose, in your working tree, and across every app of the repository.
- ⚡ IntelliSense — type
table , page , codeunit … and the next free ID is already selected. Press Enter.
- 🧹 Self-cleaning — delete or discard an object and its ID is released automatically, once it is declared nowhere else.
- 🔢 Optional field IDs — the same guarantees for the fields of tables and table extensions, per table and per app.
- 📊 License panel — load the customer's BC license once and see, per object type, how many licensed IDs are used and free.
Quick start
- Install AL ID Sentinel from the VS Code Marketplace.
- Open a workspace with AL apps (folders with an
app.json that defines idRanges).
- Run AL ID Sentinel: Sync registry with selected branches once (one developer, once per repository). Tick the remote branches
whose IDs should be known: the registry branch is created and filled from them.
- Create objects as usual. Type
table in an .al file and accept the suggested ID — it is already reserved for you.
Requirements
- VS Code 1.95+ with the AL Language extension.
- Git on your
PATH, and a repository with an origin remote.
- Permission to push the branch
users/al-object-ids/al-object-ids to origin, with no branch policies on it (no required pull
requests, no locks). It lives under users/ because Azure Repos often only allows creating branches there.
- Copilot tools need GitHub Copilot agent mode. The CLI needs Node.js.
Using it
IntelliSense
In an .al file, type the object keyword followed by a space (table , page , codeunit , enum …) or press Ctrl+Space after
it. The next free ID appears at the top of the list, preselected.
- The registry is fetched every time the list opens (waiting at most 2.5 s, then the local copy is used), so you never get an ID a colleague just took.
- Accepting the suggestion reserves the ID. If someone took that number in the meantime, the ID actually reserved is inserted and a notification tells you.
- Prefer a command? AL ID Sentinel: Reserve next ID and insert at cursor does the same from the Command Palette.
GitHub Copilot (agent mode)
The extension contributes three tools. Enable them in the chat tools picker (choose Always allow to skip the confirmation).
| Tool |
Parameters |
#allocateObjectId |
objectType (table, tableextension, page, pageextension, codeunit, report, reportextension, query, xmlport, enum, enumextension, permissionset, permissionsetextension), targetFilePath (the .al file about to be created) or appPath, optional count (1–20) |
#allocateFieldId |
targetFilePath, tableId or tableName when the file does not declare exactly one table, optional count (1–20) |
#releaseObjectId |
objectType, ids, targetFilePath or appPath |
Claude Code, Codex and scripts (CLI)
The CLI ships inside the installed extension. The folder name contains the version, so resolve it:
# PowerShell
$sentinel = (Get-ChildItem "$env:USERPROFILE\.vscode\extensions\federicoproce.al-id-sentinel-*" |
Sort-Object { [version](https://github.com/federicoproce/al-id-sentinel/blob/HEAD/$_.Name -replace '^.*-', '') } | Select-Object -Last 1).FullName
node "$sentinel\out\cli.js" allocate --type table --file "C:\repo\MyApp\src\MyTable.Table.al"
# bash
sentinel=$(ls -d ~/.vscode/extensions/federicoproce.al-id-sentinel-* | sort -V | tail -1)
node "$sentinel/out/cli.js" allocate --type table --file "/repo/MyApp/src/MyTable.Table.al"
| Command |
Purpose |
allocate --type <type> (--file <path> \| --app <dir>) [--count n] |
Reserve object ID(s) |
allocate-field (--table <n> \| --table-name <name>) (--file <path> \| --app <dir>) [--count n] |
Reserve field ID(s) |
release --type <type> --id <n>[,<n>...] (--file <path> \| --app <dir>) |
Free the IDs of deleted objects |
sync --app <dir> |
Sync the registry |
Every command prints one JSON object:
- Success:
{"app":"...","appFolder":"...","type":"table","ids":[50040],"reserved":true} → use ids.
- Failure (exit code 1):
{"error":"..."} → the caller must not invent an ID.
Teach your agents to use it
Put this in .github/copilot-instructions.md, CLAUDE.md or AGENTS.md (and remove any older ID-retrieval instruction):
## AL object and field IDs
- Before creating any new AL object, reserve its ID: in VS Code call the `allocateObjectId` tool with `objectType` and
`targetFilePath` (the full path of the .al file you are about to create); from a terminal run the AL ID Sentinel CLI
`allocate --type <type> --file <path>`. Use exactly the returned ID.
- Before adding a field to a table or table extension, reserve it the same way with `allocateFieldId` / `allocate-field`.
If the answer says the table is not managed, choose the field ID by hand following the app's idRange.
- After deleting an object, release its ID with `releaseObjectId` / `release`.
- Never invent, guess or increment IDs, and never replace a returned ID with one found by searching the workspace.
- If reservation fails, stop and report the error. Do not continue with a made-up ID.
Commands
| Command |
What it does |
| AL ID Sentinel: Reserve next ID and insert at cursor |
Reserves the next free ID for the current file's app and inserts it |
| AL ID Sentinel: Reserve next field ID and insert at cursor |
Reserves the next field ID of the table you are editing (when field IDs are on) |
| AL ID Sentinel: Sync registry with selected branches |
Rebuilds the registry from the remote branches you tick, for the apps listed in each branch's .code-workspace file. It empties the registry first (reservations included), so use it to initialise or re-initialise |
| AL ID Sentinel: Load license file… |
Stores the customer license ranges on the registry branch for the whole team |
| AL ID Sentinel: Refresh license panel |
Fetches the registry and redraws the license panel |
Releasing IDs
When an object declaration disappears (file deleted, ID changed by hand, an agent edit discarded), the extension checks whether its ID
is now an orphan: it has a registry row for the same app, and it is declared nowhere else — not in the working tree, not on any other
local or remote-tracking branch, not in the stash. If so, it fetches, checks again and deletes the row, and tells you which IDs were freed.
- Switching branches never releases anything.
- Changes within 2 seconds are grouped, and a renamed file is not a release.
- An object that still exists on another branch (e.g.
main) is kept.
- If you restore a file after its ID was released, run Sync to register it again.
Field IDs
Optional and off by default. When on, the number of every new field(<id>; ...) of a table or tableextension is reserved
too (enum values, page fields and report columns are not tracked).
| Setting |
Default |
Meaning |
alIdSentinel.fieldIds.enabled |
false |
Master switch |
alIdSentinel.fieldIds.tables |
[] |
Table numbers whose field IDs are managed (a table extension counts as the table it extends). Empty = none |
alIdSentinel.fieldIds.allTables |
false |
Manage every table (overrides tables) |
alIdSentinel.fieldIds.step |
10 |
Distance between consecutive field IDs |
Commit these settings in .vscode/settings.json or in the .code-workspace file, so the whole team and the CLI agree, and run
Sync after enabling the feature or adding tables.
{
"alIdSentinel.fieldIds.enabled": true,
"alIdSentinel.fieldIds.tables": [18, 36, 37],
"alIdSentinel.fieldIds.step": 10
}
- Key = app + table + field ID. Two apps may both extend
Sales Header with field 50000; inside one app the number is unique across all branches.
- Next = highest used + step, inside the app's
idRanges. Gaps are not refilled.
- Field IDs live in
AL-Field-IDs.md, next to AL-Object-IDs.md on the registry branch.
- A table extension says
extends "Sales Header": the number is resolved from the repository and the symbol packages in .alpackages, so download symbols first.
License panel
The AL ID Sentinel icon in the Activity Bar opens the License panel: customer → object type → license range, each with
used / assigned · free.
- Load once for the whole team: Load license file… reads the license
.txt exported from Business Central (load the full export:
besides Object Assignment it reads Module Objects and Permissions, so objects included in modules are counted) and stores only the
ranges as AL-License.md on the registry branch. The .txt itself, with the customer's address, is never copied.
- Colours: a type turns red at
alIdSentinel.license.criticalFree free IDs or fewer (default 10) and yellow at
alIdSentinel.license.warningPercent % free or less (default 20). IDs used outside every range are listed under Outside license.
- Temporary tables (
TableType = Temporary) are not counted. Only table, report, codeunit, page, xmlport and query are.
- It never blocks you: an ID outside the license is still assigned, with a warning (agents get it in the tool answer).
- One repository = one customer.
How it works
- The branch
users/al-object-ids/al-object-ids is an orphan branch with no shared history with your code. It holds
AL-Object-IDs.md — one table per object type: | ID | App | Reserved by | Date (UTC) | — and, when used, AL-Field-IDs.md and AL-License.md.
- Key = object type + ID, unique across every app of the repository. Table 50000 and codeunit 50000 can coexist; two tables 50000 cannot.
- To reserve an ID the extension fetches the branch, computes the used IDs (registry + every object in the working tree), takes the
first free one in the target app's
idRanges, commits and pushes. A rejected push means someone was faster: it retries with the next
free ID (up to 50 times).
- Each machine keeps a tiny clone of that branch only (VS Code global storage; for the CLI
%LOCALAPPDATA%\al-id-sentinel-cli).
Limits
- Enum values are not tracked; field IDs only for the tables you select.
- An ID typed by hand is not reserved until someone runs Sync. A pipeline check for duplicate IDs is a good backstop.
- Each reservation is one fetch, one commit and one push: it needs network access to
origin.
Troubleshooting
| Problem |
What to check |
| "Run Sync" instead of an ID |
The registry does not exist yet (or field IDs were enabled / tables added after the last Sync): run Sync registry with selected branches |
| Error on the first Sync |
You need permission to push users/al-object-ids/al-object-ids, and the branch must not be covered by branch policies |
| "The registry is very busy" |
Many people are reserving at the same moment: try again |
| No IntelliSense suggestion |
The file must be saved inside an app whose app.json defines idRanges |
| An agent returns an error |
It must stop and report it, not invent an ID. Fix the cause (usually Git access) and retry |
| A table name cannot be resolved |
Download symbols so .alpackages contains the base application |
| An ID is missing from the registry |
It was typed by hand or lives on a branch not ticked at the last Sync: run Sync again, ticking that branch |
Development
npm install
npm test # behaviour tests + an 8-developer concurrency test against local bare repositories
npm run package # builds out/al-id-sentinel-<version>.vsix
Press F5 in VS Code to launch an Extension Development Host. Issues and pull requests are welcome.
License
Apache 2.0 © Federico Proce
| |