Play Games

Search This Blog

Monday, November 13, 2017

How do we know whether it is sandbox or production using code?

Solution: We can know whether the instance is production or sandbox by querying on Organization object.
Example : 
Run the piece of code:
List<organization> lstOrganization = [Select id,instanceName,isSandbox from Organization];
if(lstOrganization.size()>0) {
   if(lstOrganization[0].isSandbox) {
       system.debug('Its Sandbox Instance');
   } else {
       system.debug('Its Production Instance');
   }

}
Output :

No comments:

Post a Comment