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!!!😁
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
END
Hope this will help.
Thanks for reading.
ZHU
コメント