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 determine in which sandbox (or production) the code is running



We have integrated sfdc with a document management sytem and a erp system.  We have integrated this via a portal solution.


We want to make sure that when a full copy is done from production to for instance the training sandbox dat training (integration) data is NOT placed in our integrated production environment!

Therefore I want to know in an apex class in which sfdc sandbox (or production) the apex class is running. For now I use the Userinfo.getUsername() call to determine the sandbox because the sandbox name should be placed behind the email adress.


Is this a solid method? Is there anothe api call which i can do to retrieve the current contex?


I am also interested in experiences on how to configure test/acceptance/production in integrated environments where SFDC is one of the systems







Would you be able to tell us what solution you came up with please?

Thank you very much.