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 :
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