I may be taking crazy pills, but it seems like SFDC is doing a find and replace on any strings with a production org id and replacing them with the sandbox org id when creating a sandbox. I can't seem to find this behavior documented anywhere. Has anyone else seen this?

I have a class Org_Constants which has a constant for the production org id, so I can have code behave differently in production and sandbox environments. But it never works in new sandboxes, since it ends up with the sandbox id listed for the production org id.

1 Answer 1


Yes, Salesforce replaces any references to the production org id in ALL metadata when perform a refresh. Unexpected, yes. Documented, yes.

Sandbox Help

Sandbox and production organizations always have unique organization IDs. The sandbox copy engine creates a new organization as part of each creation and refresh request. So, the organization ID of your sandbox changes each time your sandbox is refreshed. Salesforce inserts the new value in any place the organization ID is used, such as text values and metadata.

  • I know from experience that they do replace the org id between production and sandboxes.
    – rlewi17
    Commented Nov 11, 2014 at 23:11
  • If you do want a snapshot of your Production Org Id in your Sandboxes, use a Custom Setting. The refresh process will not replace the Org Id in the Custom Setting. Commented Jul 6, 2017 at 1:34

You must log in to answer this question.

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