Deprecating code
Deprecating code in Business Central AL extensions: how to mark code obsolete with preprocessor directives and Obsolete properties, Microsoft's timeline for removal, and the deprecation of explicit and implicit 'with' statements. It answers questions about obsolete states, CLEAN symbols, warnings AL0604 and AL0606, and how long obsolete code stays.
Path: Development > Extension lifecycle > Deprecating code · tier official · system development · narrative reviewed (checked by Opus)
Overview
This section covers how code is retired in Business Central. It explains the practices Microsoft uses when obsoleting code in the Base App, so developers can follow the same patterns in their own extensions. It also covers one specific deprecation, the ‘with’ statement in AL.
Start with the timeline page to learn the rule: at least 12 months pass between marking code obsolete and removing it. Then read the best practices page for the mechanics, which use the ObsoleteState, ObsoleteTag and ObsoleteReason properties together with CLEAN version symbols and preprocessor directives. The ‘with’ statement page is a worked example of a deprecation, with warnings and fixes for existing code.
Key points
- Microsoft keeps a minimum of 12 months between marking code obsolete and removing it.
- Obsoleting code uses the ObsoleteState, ObsoleteTag and ObsoleteReason properties, or the Obsolete attribute.
- CLEAN symbols (CLEAN15 to CLEAN18 are named) and preprocessor directives control when obsolete code is included or removed.
- The best practices page describes how Microsoft obsoletes code in the Base App and recommends developers follow similar patterns.
- AppSourceCop is listed among the tools tied to deprecation guidelines.
- Explicit and implicit ‘with’ statements are deprecated, with warnings AL0604 and AL0606 (2022 release wave 2).
- Fixes for ‘with’ statements include pragma directives, qualifying references, and the NoImplicitWith flag.
Learn pages
- Best Practices for Deprecation of AL Code: Description of best practices and guidelines for deprecating code in the Base App for Business Central.
- Deprecating explicit and implicit with statements: Rationale and description of why explicit and implicit with statements are deprecated in AL.
- Microsoft Timeline for Deprecating Code in Business Central: Description of the timeline for deprecating code in Business Central.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #10341 Remove Anthropic privacy notice from Expense Agent (code change): “Anthropic privacy notice components are removed from Expense Agent”
- #12066 Bugs/remove asm inv mfg clean27 tags for wave2 2026 (code change): “Removes the obsolete code that was kept under CLEAN27 conditional compilation”
- #9572 Obsolete E-Document Purchase Order Matching Copilot (code change): “Five Copilot-specific objects are marked ObsoleteState = Pending”
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.