Best Practices: Environment Checks in NetSuite

function checkEnvironment() {
        let environment = runtime.envType;
        if (environment === runtime.EnvType.PRODUCTION) {
            log.debug('Environment Check', 'This is the PRODUCTION environment.');
        } else {
            log.debug('Environment Check', 'This is NOT the production environment: ' + environment);
        }
        return environment;
    }

Function Details:

  • runtime.envType returns one of the following values from runtime.EnvType:
  • SANDBOX
  • PRODUCTION
  • BETA
  • INTERNAL
  • DEVELOPMENT
  • This is governance-free and safe to call in any script type.

Leave a comment

Your email address will not be published. Required fields are marked *