How to remove fields and procedures without breaking extensions

MB-820 · Install, develop and deploy extensions · Updated

In an AppSource or per-tenant extension you can’t just delete a field, table or procedure. Other extensions may depend on it, and deleting a field is a breaking schema change. Business Central gives you a two-step deprecation path instead.

Fields, tables and other objects: ObsoleteState

Step 1: mark it Pending. The element still works, but anyone who uses it gets a compiler warning.

field(10; Description; Text[100])
{
    ObsoleteState = Pending;
    ObsoleteReason = 'Not in use. Use the new Issue Type table instead.';
    ObsoleteTag = '2.0';
}

Step 2: mark it Removed in a later version. Code can no longer reference it (compiler error), but the schema and data stay in place.

field(10; Description; Text[100])
{
    ObsoleteState = Removed;
    ObsoleteReason = 'Not in use. Use the new Issue Type table instead.';
    ObsoleteTag = '2.1';
}

Procedures: the [Obsolete] attribute

Procedures, events and similar code elements don’t have an ObsoleteState property. Use the attribute instead:

[Obsolete('Not in use anymore.', '2.0')]
procedure Clone(var NewIssue: Record Issue)
begin
end;

Quick reference

ElementHow to deprecate
Table, field, key, page control, enum valueObsoleteState = Pending, later Removed
Procedure, event[Obsolete('reason', 'tag')] attribute
AnythingNever delete straight away

Exam traps

“Set the procedure’s ObsoleteState” is always wrong. Procedures use the attribute.

“Remove the field in version X” is wrong when other extensions depend on it. Deprecate first.

Learn more: Best practices for deprecation of AL code.

Practice questions

Pick an answer to check it. Questions are original and written for practice.

1. Version 1.0 of your app has a table field that other extensions depend on. You no longer need it. What should you do first in version 2.0?

Show answer

Answer: B.Start with ObsoleteState = Pending. The field still works, but dependent extensions get a warning so they have time to stop using it.

2. How do you mark an AL procedure as obsolete?

Show answer

Answer: B.Procedures don't have an ObsoleteState property. You decorate them with the [Obsolete] attribute instead.

3. A field has had ObsoleteState = Pending for a full release cycle. What is the next step?

Show answer

Answer: A.After the warning period, set ObsoleteState = Removed. The field can no longer be referenced from code, and the schema stays consistent for upgrades.

Keep going