How to get Business Central Environment Related Attributes?

If you want to get the details about the environment you don’t have to reinvent the wheel, you can simply use the standard codeunit Microsoft has introduced. If you look into the codeunit 457 “Environment Information”, you will see there are many procedures that fetch attributes concerning the environment of the service on which the tenant is hosted. Codeunit 457 is part of the System Application.Source.

Below are some of the procedures available in the codeunit 457

IsProduction( )
Below function will return true if the environment type is Production.

Example:

    procedure DisplayEnvironmentType()
    var
        EnvironmentInformation: Codeunit "Environment Information";
    begin
        if EnvironmentInformation.IsProduction() then
            Message('Production Environment')
        else
            Message('Not a Production Environment');
    end;

GetEnvironmentName( )

Below function will return the environment name

Example:

    procedure DisplayEnvironmentName()
    var
        EnvironmentInformation: Codeunit "Environment Information";
    begin
        Message('%1', EnvironmentInformation.GetEnvironmentName());
    end;

Below are the rest of the functions and all of them are pretty self-explanatory.

Happy coding!

Thank you and Regards,
Tharanga Chandrasekara

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

Your email address will not be published.

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