Add an unprefixed field to a standard table today, and the day Microsoft adds a field with the same name your update stops, and the only way out is to back up the data, uninstall your extension and put it all back. Why it happens, what Microsoft's rules actually require, where you need a prefix and where you do not, and how to check your own extensions.
Here is a mistake that costs nothing to avoid and a great deal to fix. Your developer adds a field to the Customer table through a table extension and calls it Credit Insurance Limit. No prefix, because why would it need one? It works perfectly for three years. Then Microsoft adds a field with exactly the same name to the same table in a new release, and your next update fails.
This is not a theoretical risk. Microsoft's own documentation uses a real example: a partner's extension added a field called Shipping Agent Service Code to the Sales Cr.Memo Header table, and Microsoft then added a field with the same name in version 17. This post explains what happens when that occurs, why the fix is so painful, and the simple habit that prevents it.
In Business Central, every extension installed in an environment shares one set of names. Two fields with the same name cannot exist on the same table, whoever added them. During an update, Microsoft recompiles your per-tenant extension against the new Base Application, and the compile fails with an error like this:
A member of type Field with name "Shipping Agent Service Code" is already
defined in Table "Sales Cr.Memo Header" by the extension
"Base Application by Microsoft (17.0.0.0)".
Microsoft then cancels the update of that environment and emails the error to the administrator. Your environment stays on the old version until you fix your extension.
The obvious fix is to rename your field or remove it and publish a new version. Business Central will not let you. Business Central online does not allow table fields to be renamed or removed implicitly, because the field holds data. Microsoft's own rule for apps, AppSourceCop AS0005, says it plainly: fields must not change name, even when they are obsolete. Try to publish a version without the field and you get a schema synchronisation error instead.
So the way out, as Microsoft documents it, is to remove the field forcefully:
That is a day or more of careful work, with real risk to data, to fix a problem caused by one missing word. And it happens on Microsoft's timetable, not yours.
If the field had been called BBX Credit Insurance Limit, Microsoft adding its own Credit Insurance Limit would not matter: the names are different, and both fields live happily side by side. That is the whole idea. Microsoft calls it an affix, because it can go at the start (prefix) or the end (suffix) of the name.
namespace BusinessBoxed.PalletManager;
using Microsoft.Sales.Customer;
tableextension 50110 "BBX Customer" extends Customer
{
fields
{
field(50100; "BBX Credit Insurance Limit"; Decimal)
{
Caption = 'Credit Insurance Limit';
DataClassification = CustomerContent;
}
}
}
Notice the Caption. Users never see the prefix; they see "Credit Insurance Limit". The prefix is in the name, which only developers and the database see. There is no downside for users at all.
PTE if you have nothing better. In practice, use your own three letters (we use BBX).BusinessBoxed.PalletManager.| What you are adding | Prefix? | Why |
|---|---|---|
| Fields in a table extension | Always | The most important one. A clash blocks the update, and the field holds data, so the fix is the export, uninstall and reimport above. |
| Enum values in an enum extension | Always | Enum values are stored in records. A clash with a value Microsoft adds is just as awkward as a field. |
| Procedures in a table or page extension | Always | If Microsoft adds a procedure with the same name and parameters, code calling yours can break (AppSourceCop AS0079). |
| Your own new tables, pages and codeunits | Prefix or namespace | Object names must be unique across every extension installed. A two-level namespace or a prefix on the object name both work. |
| Fields inside your own new tables | Not needed | The table is yours, so nobody else can add a field to it except through their own table extension, and they should be prefixing theirs. |
| Controls and actions in a page extension | Yes | They can clash too, and Microsoft's rules require an affix. A clash here is easier to fix, because pages hold no data, but it still stops the update until it is fixed. |
So the priority is exactly where you would expect: anything that holds data on a table you do not own. Table extension fields first, enum extension values second, everything else because it is free to do.
pageextension 50110 "BBX Customer Card" extends "Customer Card"
{
layout
{
addlast(General)
{
field("BBX Credit Insurance Limit"; Rec."BBX Credit Insurance Limit")
{
ApplicationArea = All;
}
}
}
actions
{
addlast(processing)
{
action(BBXCheckCreditInsurance)
{
Caption = 'Check Credit Insurance';
ApplicationArea = All;
Image = Check;
}
}
}
}
Do not rely on developers remembering. Switch on the AppSourceCop code analyser, even for a per-tenant extension, and give it your affix in an AppSourceCop.json file at the root of the project:
{
"mandatoryAffixes": [ "BBX" ]
}
Rule AS0011 then flags every new object, field and table extension element that is missing the affix, before the code ever reaches a customer. If you do not want the rest of AppSourceCop's rules on a per-tenant extension, use a ruleset to turn off the ones that do not apply and keep AS0011, AS0079 and AS0098.
Names are not the only thing that must be unique. Every object also needs an ID that nothing else in the environment uses. Microsoft reserves 50,000 to 99,999 for per-tenant extensions, and AppSource publishers are given their own ranges. If two extensions on the same environment use the same IDs, the second will not install. Agree an ID range for each extension, keep it in app.json, and use a tool such as AL Object ID Ninja if several developers work on the same app.
Many older extensions do, especially ones converted from NAV. A practical approach:
Region, Priority or Credit Limit Date on a standard table is the kind of name Microsoft might use one day. A very specific name is less likely to clash, but there is no guarantee.Every field you add to someone else's table, every enum value you add to someone else's enum, and every procedure, control and action you add to someone else's object needs your prefix. Your own tables need a prefix or a namespace, and the fields inside them do not. The prefix costs three characters and is invisible to users; leaving it off can stop your update and force a data migration on Microsoft's timetable.
This builds on part 4 of our AL development series on table extensions and enums, and the full series starts at AL development from scratch. If you would like us to check your extensions for unprefixed fields before your next update, our AL code check does exactly that, or book a 30-minute call.