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.


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. – gogorichie Nov 11 '14 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. – John Thompson Jul 6 '17 at 1:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.