Last active
June 11, 2021 20:30
-
-
Save conrjac/5c154cea666027e0750e5afb013a9452 to your computer and use it in GitHub Desktop.
Determine Org Type via Apex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Controller/Trigger calling: | |
system.debug(' o ' + Utility.isSandbox()); | |
' If Statement Example | |
If(Utility.isSandbox()) | |
{ | |
' Run this code, as current enviroment is a sandbox | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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