+ Start a Discussion
pareshjenapareshjena 

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 "Force.com Sandbox: SFDPOC". The string "SFDPOC" is the environment name. How to get this value "SFDPOC" in a trigger?

DTCFDTCF

Probably best to use:

 

String orgId = UserInfo.getOrganizationId();