You need to sign in to do that
Don't have an account?

Code that finds difference between sandbox and production environment.
Hi,
I have an external wsdl which has been parsed into apex classes. There is an endpoint to it and the end point is different for production and sandbox. The sandbox should point out to sandbox endpoint of the external wsdl and the production points out to the production wsdl endpoint. Is there any way so that i can write a code which can help me in detecting the environment so that the code determines if the environment is sandbox then endpoint points to the sandbox wsdl.
You can save the organisation id for your production org in a custom setting/custom label (get the organisation id from Company profile -> Company Information). Now in your code compare the org in which the org is runnung (UserInfo.getOrganizationId) to the prod org id.
example:
If(UserInfo.getOrganizationId() == Label.production_org_id)
if true: the org is production
if false: org is a sandbox
Anand
All Answers
You can save the organisation id for your production org in a custom setting/custom label (get the organisation id from Company profile -> Company Information). Now in your code compare the org in which the org is runnung (UserInfo.getOrganizationId) to the prod org id.
example:
If(UserInfo.getOrganizationId() == Label.production_org_id)
if true: the org is production
if false: org is a sandbox
Anand
Here's some code I've used to figure out whether I'm on a sandbox or production:
http://www.salesforcefast.com/2012/07/what-type-of-salesforce-org-am-i.html
Good luck!