Server Variables in Qntrl Efficient Script Automation | Qntrl Online Help

Server Variables

A Server Variable is used to store values such as text, numbers, email addresses, or any reusable data, and access them across scripts. This helps improve maintainability by avoiding hardcoded values in multiple places.
Instead of updating values in every script, you can update the value in the server variable once, and the change will automatically reflect wherever it is used.


Example:
If multiple scripts use the same email address, you can create a server variable named support_email.
  1. Use the variable in scripts instead of hardcoding the email
  2. If the email changes, update it in the server variable
  3. All scripts will automatically use the updated value
This ensures consistency and reduces maintenance effort.
 

Scope of Server Variables  

Server variables support two scopes:

  1. Global: Use this when the value is common across the application
    1. Accessible across all scripts
    2. Same value is used everywhere
    3. Example: Support email, API base URL
  2. Script: Use this when the value varies based on the script
    1. Accessible only in selected scripts
    2. Allows different values for each script
    3. Example: Memory limits, thresholds, or environment-specific values

Create a Server Variable   

  1. Navigate to (settings) >> CodeX >> click Server Variables in the menu.
  2. Click the New Variable button.
  3. Provide the following details:
    1. Name : Enter a name for the variable.
    2. Description : Provide a description for the variable.
    3. Scope : Choose a scope type for the variable.
      1. Global - Available across all scripts
        1. Value: Enter a value for the variable
      2. Script - Available only in selected scripts
        1. Script: Select the scripts where you want to use the variable
        2. Script Values : Enter the value for each selected script
  4. Click Save.

      

Notes

You can add a maximum of 10 script variables and 25 global variables.


Using Server Variables in Scripts

You can access a server variable inside a script using:
 

      ZDK.Vars.getScriptVariable("<variable_name>");

Example:      
      var count = ZDK.Vars.getScriptVariable("SDK_Count");

This retrieves the value based on:

  1. Global value (if scope is Global)
  2. Script-specific value (if scope is Script) 

Edit or Delete a Server Variable   

To edit server variable details:
  1. Navigate to (settings) >> CodeX >> click Server Variables in the menu.

  2. Click on the variable you want to edit/Delete.

    1. Select Edit to modify the variable's value or other settings.

    2. Select the Delete to remove the variable. 

       

Notes
Deleted server variable can no longer be used in the CodeX script.

Enable or Disable Server Variables   

When a server variable is disabled, it cannot be used in the codex script.
  1. Navigate to (settings) >> CodeX >> click Server Variables in the menu.
  2. In Active column, toggle the button to enable or disable the required server variables.
      



    • Related Articles

    • Create and Configure a CodeX Script

      Prerequisite Prior to creating a codex, it is essential to establish a board since the configured codex scripts can be activated within that Board when specific conditions arise. Create and Configure a Script Enable and use AI code assistant from ...
    • Summary

      Overview CodeX, a robust scripting feature within the Qntrl platform, empowers you to automate tasks, manipulate data, and integrate workflows/applications. By running JavaScript code in a standalone server environment, CodeX allows you to execute ...
    • Script Modules

      Early Access Script module is not enabled for all users. If you’d like to try it out, please email our support team for early access. Script Modules offers creating reusable, ready-made templates for your business logic compatible with ES6 modules. ...
    • Parameters in CodeX Script

      In the CodeX script, you can perform CRUD (Create, Read, Update, Delete) operations on the Parameters in Qntrl through the SDK. Instead of defining a URL or other values directly in your CodeX script, you can define them in ConfigStore and reference ...
    • Qntrl 3.0: new updates and migration

      Latest additions and enhancements We recently released a new version of Qntrl: 3.0. This version has a fresh interface with simplified navigation and seamless performance. We’ve tried to incorporate as many feedback and suggestions as possible in our ...