How do I detect the environment in Salesforce?

Posted by Craig Harris on Stack Overflow See other posts from Stack Overflow or by Craig Harris
Published on 2009-10-02T04:20:53Z Indexed on 2010/04/13 21:23 UTC
Read the original article Hit count: 414

Filed under:
|
|

I am integrating our back end systems with Salesforce using the web services. I have production and stage environments running on different URLs. I need to be able to have the endpoint of the web service call be different depending on whether the code is running in the production or sandbox Salesforce instance.

How do I detect the environment.

Currently I am considering looking up a user to see if there user name ends in 'devsandbox' as I have been unable to identify a system object that I can query to get the environment.

Further clarification:

The location I need to determine this is within the Apex code that is invoked when I select a button in Salesforce. My custom controller needs to know if it running in the production or sandbox Salesforce environment.

© Stack Overflow or respective owner

Related posts about salesforce

Related posts about apex