I am trying to create a class to set specific configurations on a sandbox depending on the type of license the sandbox has after the sandbox is Refreshed.

All I've been able to do is to tell if it is Production or a Sandbox but not what kind of sandbox.


The InstanceName should contain QA, UAT, Dev, etc.

There is no straight forward way for this.

You can check by InstanceName in the Organization field:

SELECT InstanceName FROM Organization

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:

Prod: CompanyName
Sandbox: CompanyName.UAT
Sandbox: CompanyName.QA
Sandbox: CompanyName.DEV
Sandbox: CompanyName.DEVPRO

You will be able to query the 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. Thanks.

| improve this answer | |

How about using:

SELECT OrganizationType, IsSandbox, Name FROM Organization

Note that the "InstanceName" suggested by Abhishek is a value like "CS68" etc. and is the name of the Salesforce Instance on which the org resides. You can use the "Name" instead in the way suggested though.

Take a look at the documentation for further info.

| improve this answer | |

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.