How to get the current sandbox-name programmatically (dynamically) via APEX?
There is now an official solution that is out with the Spring' 22 release.
You can use the new getSandboxName() method:
System.Domain d = System.DomainParser.parse(URL.getOrgDomainUrl());
System.debug(d.getSandboxName());
You can get more information about this new method in the Apex Reference Guide here.
There are also so other new and useful methods like getMyDomainName().
Comments
Post a Comment