web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

only be visible or enabled when the environment is Production

(8) ShareShare
ReportReport
Posted on by 188
Dear all
I want to create an action on a page that should only be visible or enabled when the environment is Production, and hidden/disabled in Sandbox or Development. What is the recommended approach in AL to conditionally control actions based on the current environment?
 
thank you
I have the same question (0)
  • Verified answer
    Sahan Hasitha Profile Picture
    2,674 on at
    only be visible or enabled when the environment is Production
    hi
     
    you can use the Environment Information page provides key details about the current tenant and environment. It shows whether you are working in Production or Sandbox, the environment name, region, and version details. This information is useful for administrators and developers to quickly verify where they are working, especially when multiple environments exist, and helps ensure that changes or tests are performed in the correct place
  • Verified answer
    Sahan Hasitha Profile Picture
    2,674 on at
    only be visible or enabled when the environment is Production
    hi 
    thy this
  • Suggested answer
    Rishabh Kanaskar Profile Picture
    5,474 on at
    only be visible or enabled when the environment is Production
    Hi,
     
    Use Session.CurrentEnvironment() in AL.
    Example:
     
    actions
    {
        addlast(processing)
        {
            action(MyProdOnlyAction)
            {
                ApplicationArea = All;
                Caption = 'Prod Action';
                Visible = Session.CurrentEnvironment() = 'Production';
            }
        }
    }

    This ensures the action is only visible when the environment is Production.
     
    Thanks
    Rishabh
  • Suggested answer
    Nimsara Jayathilaka. Profile Picture
    4,826 on at
    only be visible or enabled when the environment is Production
    Hi
     
    You can use "Environment Informations" Codeunit.
    There are different procedures Check whether if it is Production , OnPrem , SaaS...etc
  • Sumit Singh Profile Picture
    8,937 on at
    only be visible or enabled when the environment is Production
    Hi Everyone,
     
    I think this query is already resolved and also having verified answer, so no need to revert on this. Thanks!
  • Suggested answer
    YUN ZHU Profile Picture
    93,874 Super User 2025 Season 2 on at
    only be visible or enabled when the environment is Production
    Just add some info:
    Dynamics 365 Business Central: How to quickly get the current environment name, environment type, and deployment type via AL
     
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,225

#2
Sumit Singh Profile Picture

Sumit Singh 2,123

#3
YUN ZHU Profile Picture

YUN ZHU 1,813 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans