Skip to content

Instantly share code, notes, and snippets.

@conrjac
Last active June 11, 2021 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conrjac/5c154cea666027e0750e5afb013a9452 to your computer and use it in GitHub Desktop.
Save conrjac/5c154cea666027e0750e5afb013a9452 to your computer and use it in GitHub Desktop.
Determine Org Type via Apex
' Controller/Trigger calling:
system.debug(' o ' + Utility.isSandbox());
' If Statement Example
If(Utility.isSandbox())
{
' Run this code, as current enviroment is a sandbox
}
public class Utility {
public static Boolean sandboxBool;
public static Boolean isSandbox()
{
if ( sandboxBool == null ) sandboxBool = URL.getSalesforceBaseUrl().getHost().left(2).equalsignorecase('cs');
return sandboxBool;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment