function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Denver GreeneDenver Greene 

Get new org id after sandbox refresh

When I refresh a sandbox the org id changes. This causes links with external systems to break and so they need to be updated. Is there any way for developers to get the org ID automatically, without having to log in to the sandbox? Ideally this would happen in the sandbox post refresh apex class that runs automatically.

I was initially going to try sending an email, but in the post refresh you can only send system emails. I could log in and change the email deliverability settings, but then it can't happen as part of the refresh which is kind of the whole point.

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

Go to your production and you can able to find the new sandbox ids 

1. From Setup, enter Sandboxes in the Quick Find box.
2. Select Sandboxes.

You can able to find the sandbox id  after refresh 
Denver GreeneDenver Greene
I was hoping for a way to send out the id using automation whenever the sandbox is refreshed. This way it would all happen automatically. I was looking at ways to do it in the postrefresh sandbox apex class thing, but email is not an option for that.