function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to get Sandbox/environment name in trigger

We are building some logic in apex trigger to find out which environment  (sandbox/production) we are in. How to get the value of this.


For example: when we are in our sales force sandbox  UI, it shows " Sandbox: SFDPOC". The string "SFDPOC" is the environment name. How to get this value "SFDPOC" in a trigger?


Probably best to use:


String orgId = UserInfo.getOrganizationId();