Server Variable is a feature for storing values, such as text, numbers, email addresses, or any other data, and reusing values across your scripts, making your scripts more efficient and easier to manage. If you need to update these values, you can do it in the server variable, and this change will be reflected across multiple parts of your script or application.
For example, if you have a commonly used email address in multiple scripts, create a server variable called "vendor_email" to store it. Then, in any script that requires this email address instead of typing it out, just call the "vendor_email" variable, and it will dynamically retrieves the email address. If the vendor's email changes, update it in the server variable, and all your scripts will automatically use the new email address, saving time and ensuring data consistency.
Server variables come in two scopes, each with specific accessibility:
Global: When set as 'Global', you enable its use in all scripts, making it accessible from anywhere in your code.
Script: Setting the scope as 'Script' limits its use to specific scripts, restricting its accessibility to only those parts of your code.
Create a Server Variable
Navigate to (settings) >> CodeX >> click Server Variables in the menu. Click the New Variable button.
Provide the following details:
Name : Enter a name for the variable.
Description : Provide a description for the variable.
Scope : Choose a scope type for the variable.
Click Save.
You can add a maximum of 10 script variables and 25 global variables.
Edit or Delete a Server Variable
To edit server variable details:
Navigate to (settings) >> Scripts >> click Server Variables in the menu.
Click on the variable you want to edit/Delete.
Select Edit to modify the variable's value or other settings.
Select the Delete to remove the variable.
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.
Navigate to (settings) >> CodeX >> click Server Variables in the menu. In Active column, toggle the button to enable or disable the required server variables.