Dynamics 365 Business Central: how to detect if your extension is running on a Sandbox

During our Extension Development workshops for Dynamics 365 Business Central, some developers are start asking for scenarios where in my extension I need to detect if it’s running on a Sandbox environment or in a production one.

From an extension, you can detect if it’s running on a Sandbox environment by using the Tenant Management codeunit (417). This codeunit provides a set of useful functions for retrieving informations about the Dynamics 365 Business Central tenant and platform. Here is a quick sample:


In order to retrieve if your extension is running on a sandbox or on a production tenant, you can call the IsSandbox or IsProduction methods respectively.

You can also retrieve informations about the tenant, like Tenant ID and Name, Platform version and Application version by calling the functions I’ve showed in the second message in my AL code.

When running this simple extension from Visual Studio Code, this is the output you obtain:


and these are the tenant and platform informations (these are related to my sandbox version):


There’s also a second way to retrieve if an extension is running on a sandbox and it’s by using the Permission Manager codeunit (9002) and its IsSandboxConfiguration method:


This is only an alternative way because this second function calls the function defined in Tenant Management codeunit.


  1. I’m happy to say that we have simplified this process by adding helper functions in COD2300 for the Business Central Fall 2018 release:

    Liked by 1 person

  2. Seems like the codeunit is now 457 “Environment Information”.
    Would be nice to get more background information about how the following DotNet variables used in 457 and 2300 work:

    TenantLicenseStatePeriodProvider: DotNet TenantLicenseStatePeriodProvider;
    TenantLicenseStateProvider: DotNet TenantLicenseStateProvider;

    The readme.md does not give that much extra information.


  3. Codeunit 457 has method GetApplicationFamily().
    Is this always the 2 letters of the localization; W1, US, NL, IT, ….?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.