topic hubAL Developmentofficial - Microsoftreviewed - checked by Opus

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

Videos, posts and code changes

Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.

Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.

What Learn documents here 3 Learn pages