community postAL Developmentcommunity - not Microsoftreviewed - checked by Opus

Understanding AL Development: Environmental Information Code Unit

Codeunit 457 Environment Information provides methods to detect deployment type, environment type, and application family in AL extensions. It helps developers run different code paths for production versus sandbox environments, such as redirecting emails in sandbox to safe addresses instead of real clients.

post Aardvark Labs

Marcel Chabot · 2025-11-07 · 381 words · about 2 min

"There are cases where we want some different behavior depending on specific environmental details."

Key points

  • Codeunit 457 Environment Information exposes methods like IsProduction, IsSandbox, IsSaaS, IsOnPrem, and IsFinancials to check environment characteristics
  • IsProduction and IsSandbox are useful for gating operations, such as skipping email sends or redirecting to test addresses in sandbox
  • IsSaaSInfrastructure distinguishes between SaaS infrastructure hosting and Docker testing environments, returning false in Docker
  • CanStartSession checks if a new session can be started via Session.StartSession for multi-session processing
  • Common use case is preventing sensitive operations like sending remittance notices to real customers when a production environment copy exists in sandbox

Quotes

  • “There are cases where we want some different behavior depending on specific environmental details.” (Explains why developers need to detect and respond to environment differences in their code)
  • “If someone makes a copy of the Production environment to a Sandbox, we want to change this behavior.” (Illustrates the critical security use case of preventing unintended operations like sending real emails from sandbox copies)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

Context

  • Features: environment type detection, sandbox vs production checks, SaaS infrastructure detection, on-premises detection, application family identification, environment name retrieval, linked Power Platform environment detection

Source: Aardvark Labs, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.