Overview

The Environment attribute is a Zoho Creator specific, system variable that returns the current runtime environment of the application. It allows you to write environment-aware Deluge scripts that behave appropriately across development, stage, and production environments.

Use this attribute to implement environment-based logic, control integrations, and ensure safe execution during testing and deployment.

Syntax

To fetch the current environment type of the application,

thisapp.environment.type

To fetch the linkname(unique identifier) of the current environment,

thisapp.environment.linkname

Returns

AttributeDescription
thisapp.environment.typeReturns the base environment type, such as development, stage, or production. This is commonly used in conditional logic to control application behavior across environments.
thisapp.environment.linknameReturns the specific link name of the environment. This is typically used when constructing URLs or passing environment context in API calls.
Note: For default environments, both thisapp.environment.type and thisapp.environment.linkname return the same value. However, they are designed for different use cases. It is recommended to use each attribute according to its intended purpose.

Usage

thisapp.environment.type – Use this when controlling runtime behavior within scripts based on the base environment (development, stage, or production). Common use cases include:

  • Controlling external system integrations
  • Enabling or restricting feature execution
  • Applying environment-specific business rules
  • Preventing live actions during testing

thisapp.environment.linkname – Use this when constructing environment-aware URLs or passing environment context in API calls. Common use cases include:

  • invokeURL calls
  • Internal API routing
  • Cross-app communication within the same environments
  • Dynamic URL generation

Examples

Example 1: Syncing records to an external CRM

In a Lead Management application, customer inquiries submitted through a form (such as name, email address, company, and interest details) are captured as lead records and synchronized with an external CRM system for sales follow-up and tracking.

During development or stage testing, syncing test data to the live CRM can create unwanted or inaccurate records in the production system.

To prevent this, you can use the application’s environment context to control when the CRM integration executes. By using thisapp.environment.type, the workflow ensures that records are synced only when the application is running in the production environment. In development or stage, the integration is skipped.

if (thisapp.environment.type == "production")
{
    response = invokeUrl
    [
        url : "https://api.external-crm.com/leads"
        type : POST
        parameters : leadData
    ];
}
else
{
    info "CRM sync skipped in non-production environment.";
}

Example 2: Routing API Calls Dynamically

In an Inventory Management application, a custom function retrieves order records from the Orders form using an internal API call. The application is deployed across development, stage, and production environments.

Since the application runs in multiple environments, the API request must be routed to the corresponding environment instance. Instead of using static environment values, you can use thisapp.environment.linkname to dynamically align both the API path and the request header with the current runtime context.
This approach allows the same script to work seamlessly across all environments without modification.

apiUrl = "https://www.zohoapis.com/creator/v2.1/data/org_name/app_link_name/form/Orders";

response = invokeUrl [
    url : apiUrl,
    type : POST,
    headers : {"environment" : thisapp.environment.linkname}
];

Points to note

  • When Creator APIs are invoked from external systems, the environment must be explicitly specified using request headers, as "thisapp.environment" is not resolved outside Creator.