We have a constant URL string pointing to a staging webservice. When deploying change sets to Production, we would like this constant URL to change to the production webservice. Is there a way for a change set to automatically do this transformation during deployment? (Basically, the way it works publishing debug/release versions in .Net.)

Alternatively, I can create a class called Constants containing Production constants, and deploy it once, then modify it to contains staging constants in my sandbox during development. I was just wondering if there is another more automated way.

1 Answer 1


You cannot run code automatically after a changeset deployment, unless you use ant or something similar to do the deployment.

However, what you can do is change your code ever so slightly and handle logic differently whether you're in Sandbox or not. For example

Boolean isSandbox = [SELECT IsSandbox FROM Organization LIMIT 1].IsSandbox;
String myString = (isSandbox) ? 'ToSandbox' : 'ToProduction';
  • 1
    Hmm, I'm surprised Salesforce doesn't have something like a constants table for dev/prod. In the meantime, thanks, that's exactly what I needed.
    – Dave
    Apr 13, 2017 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .