Posts

Showing posts with the label Production

Determine whether the Salesforce organization is a Sandbox or a Production

To determine if a Salesforce organization is a sandbox or a production environment in Apex. Salesforce's sObject Organization has a field called IsSandbox, which is true for sandboxes and false for Production. Boolean isSandbox = UserInfo.getIsSandbox(); Organization org = [Select Id, Name, IsSandbox from Organization]; if (org.isSandbox) {     System.debug('The organization is a sandbox.'); } else {     System.debug('The organization is a production environment.'); } You can use this check to conditionally execute logic based on whether the Apex code is running in a sandbox or production environment. This can be useful for implementing different behaviors or configurations specific to each environment. In Salesforce, the Organization object represents metadata and settings for a Salesforce organization. It provides information about the organization's configuration, such as its name, address, edition, features, limits, and more. The Organization object is rep...