I need to check the type of Sandbox to verify whether it is one of the following
- Partial Copy Sandbox
- Full Sandbox
- Developer Sandbox
The Organization object helps in identifying if its a sandbox as follows:
[SELECT Id, isSandbox FROM Organization LIMIT 1].isSandbox
But, how to check the Type of Sandbox?
Best Answer
I don't think there's a straightforward solution.
As you've said, we have the Organization SObject which we can query to find certain environment information, such as:
This will tell us if we're on a sandbox environment, but it won't tell us which of sandbox it is.
The best solution I can offer is to include sandbox type in the sandbox type when creating them.
So if you have the following environments:
You will be able to query Organization.Name to find the current environment type.
It's pretty messy and requires the use of a naming convention in order to work, but I think it's the easiest way for now. Probably worth a post on the Ideas site, as it would be a pretty useful feature.