Deprecating code
Deprecating code in Business Central AL covers how code is marked obsolete and how to handle deprecated language constructs. It answers questions about preprocessor symbols and obsolete attributes, and about the deprecation of explicit and implicit 'with' statements.
Path: Deprecated features > Deprecating code · tier official · system none · narrative reviewed (checked by Opus)
Overview
This section has two pages on deprecation in AL code. The first describes how Microsoft obsoletes code in the Base App, using preprocessor statements and the obsolete properties, and gives developers guidance to follow the same patterns in their own code.
The second page covers a specific language deprecation: explicit and implicit ‘with’ statements. It explains the related warnings and the ways to keep code safe during platform upgrades.
Start with the best practices page if you are obsoleting your own objects or members. Read the ‘with’ statements page if you see AL0604 or AL0606 warnings or need to prepare code for the change.
Key points
- Deprecation in AL uses preprocessor directives together with the ObsoleteState, ObsoleteTag and ObsoleteReason properties.
- CLEAN version symbols (CLEAN15, CLEAN16, CLEAN17, CLEAN18) are used in the Base App to control obsoleted code.
- Microsoft’s own Base App obsoletion pattern is the model developers are advised to follow.
- Explicit and implicit ‘with’ statements are deprecated in AL; the page on this refers to 2022 release wave 2.
- The AL0604 and AL0606 warnings relate to the ‘with’ statement deprecation.
- Fixes for ‘with’ statements include pragma directives, adding qualifications, 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.
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.