Skip to main content

Global Variables

Global Variables let you define reusable values—either hardcoded or calculated dynamically—for use across Nectari. These variables can be referenced throughout the platform (for example, in filters, column headings, selection pages, calculations, or translations).

You can use global variables in the SQL Script Builder in the Data Model Designer for calculations, or as column headings in translations.

When to use global variables

  • Standardizing dynamic values: Store values, such as the company name, current fiscal period, or default currency, that should be reused across multiple reports or dashboards.
  • Centralizing custom logic: Manage complex or frequently updated calculations in a single place, so updates are reflected everywhere the variable is used.
  • Automating context-sensitive content: Use scripts to generate context-specific text, labels, or data that update automatically as business logic or environment changes.

Create a global variable

  1. From the navigation panel, click the gear icon at the bottom. The Administration page opens.
  2. Select Global Variables from the menu.
  3. Click Add New Record.
  4. Enter the required fields.
  5. (Optional) If you choose Javascript as the type, click Evaluate Expression to preview the result of your script.
  6. Click Create.

Global variables properties

FieldDescription
KeyEnter a unique identifier. Keys must start with @@ and are typically uppercase (@@DATE, @@USER).
DescriptionEnter a description to help identify the purpose of the variable.
Type of the global variableChoose between:

  • Constant – Hardcoded value
  • Javascript – Dynamic value
Data TypeSelect the expected data type for the variable.
Data Source(If type is JavaScript) Select the source of data used in the script.
Script(If type is JavaScript) Enter the JavaScript code manually, or click JavaScript Builder to build or insert a script.
Result(If type is JavaScript) Click Evaluate Expression.

  • If executed successfully, the result displays in green.
  • If there is an error, an Invalid Expression Syntax message appears.

JavaScript builder

The JavaScript Builder helps you write, validate, and test scripts for dynamic global variables. Use this tool to build logic using functions, operators, constants, and global variables, so you can calculate values based on your data source or advanced logic.

FieldDescription
Script EditorWrite or paste your JavaScript code directly in the editor area at the top.
Code helpersUse operator and function buttons above the editor to quickly insert operators, brackets, or keywords.
Scripts KeywordsFind and insert built-in JavaScript functions, statements, operators, and constants using the left-side menu.
NectariAccess and insert Nectari-specific global variables, special functions, and special variables.
SearchType keywords to quickly locate available functions, variables, or operators to use in your script.
ValidateClick to check your script for syntax errors before confirming.

Use the JavaScript builder

  1. Click JavaScript Builder in the global variable window.
  2. Write or paste your JavaScript code in the editor.
  3. Use the panels on the left to search for and insert available functions, statements, operators, or variables.
  4. Use the code helper buttons to insert common operators and structure your script.
  5. Click Validate to check for syntax errors. If syntax is valid, a green message appears below the editor.
  6. Click Confirm to insert your script into the global variable.

tip

Use necResult = as the return value for your script.