I believe i want to use hierarchical custom settings so that in salesforce my lightning component makes a webservice external call based on the environment I'm in

  1. sandbox (dev) calls webservice-dev url
  2. sandbox (test) calls webservice-test url
  3. production calls webservice-prod url

I am going to have my apex class that gets the http request make a call to my custom settings entry

What I've tried in my apex code


this doesnt work because I need my lightning component to make this decision dynamically, a hard coded dev will simply migrate up/ become issue on a prod redeploy

talend_esb_url__c config = talend_esb_url__c.getOrgDefaults().URL__c;

this doesnt work as the org defaults are always shown (not by environment)

tried selecting organization to determine if im in a sandbox, but this doesnt work as we have more than 1 sandboxes

select Id, IsSandbox from Organization limit 1

I want to create a custom setting for a webservice callout url that I can change dynamically based on which salesforce environment I am in


this is actually a duplicate of How to get the current sandbox-name programmatically (dynamically) via APEX? basically the same situation

I'd close the question if i could

  • Please include the code you have tried and where you are stuck. – Adrian Larson Jun 12 '17 at 14:12
  • url is the only option to understand – Avijit Chakraborty Jun 12 '17 at 15:41
  • @AdrianLarson updated to hopefully make my use case / question clear – Jay Rizzi Jun 12 '17 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.