You need to sign in to do that
Don't have an account?
Sergi
Identify the enviroment
Do you know if there's any way to know in witch enviroment (production or sandbox) is running an Apex application (class, trigger...)?
I mean inside the code of course. Any "global variable" that tells the enviroment?
Ah, that would be useful. I'm not sure if there is a direct way of doing it, but I would use either of these,
1. Using 'Custom Settings' create a setting to server your purpose, or,
2. Use ApexPages.currentPage().getHeaders().get('Host'); to discover which server you are on and then decide based on the result.
Personally I'd use number one, it's quite a clean solution and can be thought of as global variables.
Custom settings can be accessed by clicking Setup > Develop > Custom settings.
Cheers,
Wes
All Answers
Hey
I don't know of a way, but if you detail what you're trying to do perhaps there could be another solution.
Cheers,
Wes
What I want is to call an external webservice from an apex trigger.
So I have the URL hardcoded in a class variable.
While developing I have to call one webservice (test enviroment) and when on production I want to call the production server.
If this class variable could be parametrized depending on the enviroment, there will be dificult to deploy the testing URL to production and so...
Ah, that would be useful. I'm not sure if there is a direct way of doing it, but I would use either of these,
1. Using 'Custom Settings' create a setting to server your purpose, or,
2. Use ApexPages.currentPage().getHeaders().get('Host'); to discover which server you are on and then decide based on the result.
Personally I'd use number one, it's quite a clean solution and can be thought of as global variables.
Custom settings can be accessed by clicking Setup > Develop > Custom settings.
Cheers,
Wes
Hi guys,
One alternative is to create a custom formula field of type text that contains API server url. From this string you can determine which system you're running in, csX, naX, emea...
Field can be deployed together with your code.
-AT