Dynamics 365 Business Central: How to quickly get the current environment name, environment type, and deployment type via AL

Dynamics 365 Business Central

Hi, Readers.
Today I would like to talk about a simple topic, how to quickly get the current environment name, environment type, and deployment type via AL.
This is not difficult, we can just use codeunit 457 “Environment Information”:

All procedures:

We can simply do the following three requirements.

1. Deployment type: On-premises or SaaS (Cloud)

procedure IsSaaS(): Checks if the deployment type is SaaS (Software as a Service).

procedure IsOnPrem(): Checks the deployment type is OnPremises.

For example,

PS: If you need to consider the Docker environment, please use procedure IsSaaSInfrastructure(), this function will return false in a Docker container.

2. Environment type: Production or Sandbox

procedure IsProduction(): Checks if environment type of tenant is Production.

procedure IsSandbox(): Checks if environment type of tenant is Sandbox.

For example,

3. Get Environment Name

procedure GetEnvironmentName(): Gets the name of the environment.

For example,

This is useful if you want your extension to be available only in the SaaS (Cloud), or only in the Sandbox, or if you want to change the behavior of each environment through settings. Give it a try!!!😁

PS:
1. Dynamics 365 Business Central: How to get the Azure Active Directory tenant domain name and ID via AL (codeunit 433 “Azure AD Tenant”)

2. Dynamics 365 Business Central mini tips: How to get Tenant GUID in AL (Not Tenant ID)

3. How to access Dynamics 365 Business Central admin center from the URL without Tenant ID

4. Dynamics 365 Business Central: How to get Microsoft Entra tenant registered country letter code and preferred language in AL

5. Dynamics 365 Business Central: How to check BaseApp version via AL (Include First-party localization)

6. Dynamics 365 Business Central: How to get the full version text in Help & Support via AL (Record daily version information)

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL