OrgShape is a delightful and elegant way to inspect your org within Apex. It surfaces the standard Organziation object details as class properties. Additionally, it provides methods for determining other things. For instance, whether or not your org has Platform Cache enabled or whether the current execution context is a SeeAllData=true unit test.
OrgShape is a library extraction from Apex Recipes
Contributions are always welcome!
See contributing.md for ways to get started.
Please adhere to this project's code of conduct.
To install or deploy OrgShape you have three options:
- SPM Install: This is the preferred method, but it requires SPM. Find out more here.
sfdx spm:install -n 'OrgShape' - Package Link: Click this link to install the OrgShape unlocked package in your org.
- Git Clone: This is an exercise left to the reader.
Id orgId = new OrgShape().Id;Boolean isMultiCurrencyOrg = new OrgShape().multiCurrencyEnabled;Note, these properties are all exposed from a Soql query to the Organization object. The query is memoized, so multiple checks of Organization properties within the same transaction only incur a single SOQL Query cost. These properties are all accessed the same way, using this formula:
new OrgShape().<<PROPERTYNAME>>Full list of properties:
orgShape.isSandboxorgShape.multiCurrencyEnabledorgShape.orgTypeorgShape.isReadOnlyorgShape.instanceNameorgShape.podNameorgShape.getFiscalYearStartMonthorgShape.idorgShape.localeorgShape.timeZoneKeyorgShape.nameorgShape.namespacePrefix
OrgShape exposes methods that determine feature availability or execution context through logically derived methods. For instance, determining if PlatformCache is enabled must be deduced by looking at other objects and aspects of the org.
Boolean platformCacheEnabled = new OrgShape().isPlatformCacheEnabled();Boolean isCodeyCrying = new OrgShape().isSeeAllDataTrue();Boolean advMultiCurrencyMangagement = new OrgShape().isAdvancedMultiCurrencyManagementEnabled();