You need to sign in to do that
Don't have an account?
Jason Bellis (Admin)
Retrieve sandbox list via API
We have a large SFDC development shop, with several dozen sandboxes.
There is a lot of churn and management around sandbox creation, deletion, maintenance, user access, etc.
We take every opportunity to create automation around these repetitive tasks.
A real impediment to the automation is the fact that we cannot programmatically get a list of sandboxes.
We have a very real need to retrieve the list of active sandboxes through the API (not via graphical user interface).
Example: a user leaves the company. We have 45 active sandboxes. We need to disable the user in each sandbox.
It was easy to automated the process, except for the fact that we cannot get the list of sandboxes.
We have to maintain this list manually in a TXT/CSV file outside of Salesforce.
Not fun, especially since even the GUI interface does not give a nice way to copy this data out to text or CSV.
(try to copy / paste off the sandbox page, you get an ugly html table needing extensive formatting in your paste target).
There is a lot of churn and management around sandbox creation, deletion, maintenance, user access, etc.
We take every opportunity to create automation around these repetitive tasks.
A real impediment to the automation is the fact that we cannot programmatically get a list of sandboxes.
We have a very real need to retrieve the list of active sandboxes through the API (not via graphical user interface).
Example: a user leaves the company. We have 45 active sandboxes. We need to disable the user in each sandbox.
It was easy to automated the process, except for the fact that we cannot get the list of sandboxes.
We have to maintain this list manually in a TXT/CSV file outside of Salesforce.
Not fun, especially since even the GUI interface does not give a nice way to copy this data out to text or CSV.
(try to copy / paste off the sandbox page, you get an ugly html table needing extensive formatting in your paste target).
I know there is no api to list the sandboxes used in an organization. But you can use a custom setting where you can store all the sandbox organization ids and populate them and use them in your apex batch job to get the list. Would that not work for you? Please click like if you like my answer..
Buyan
I.e. the username for each sandbox can be derived from sandbox name in the list -- prod_username@company.com.sandboxname
If your goal is to login to each sandbox and retrieve information, this approach may not work as you cannot have code run in a production environment logging in to another sandbox. However this can be automated using ant build scripts where you would store all the credentials of the sandbox in a text file and have ant query each sandbox using the meta data api login and activate users. I have done this and can share this with you further on this. Could you tell me what automated tasks you want to perform on each sandbox?
Buyan
We did find a "sort of work-around" to retrieve the current list of Sandbox names from production.
We found this Salesforce app called "Environment Hub".
https://partners.salesforce.com/s/education/general/Environment_Hub
Now that we installed this in our production org, we have a table that we can query which holds all the sandbox names.
SELECT Id, DisplayName, MemberEntity, Instance, IsSandbox, OrgStatus, OrgEdition
FROM EnvironmentHubMember
WHERE OrgStatus != 'Deleted'
ORDER BY DisplayName