Expressions and code
Define custom variables in Duaer
Custom variables let you store and reuse values across Duaer workflows.
What a variable is
A Duaer variable is a key and value stored for the organization or a project—not a const you declare for one run. When an expression or a Code node runs, Duaer replaces $vars.key with the value at that time.
Every value is a string. A missing value reads as undefined, and the run does not fail because of that. A run cannot change a variable—edit it on Variables. To store data for one run, use custom execution data, not a variable.
Scope: organization and project
- An organization variable is readable by every workflow in your Duaer organization. Other organizations cannot read or see it.
- A project variable is readable only in that project’s workflows.
- When both use the same key, the project variable overrides the organization one. Organization variable keys are unique within one organization; another organization can use the same key without conflict.
- Only the organization’s owner and admins can create, edit, or delete organization variables. Whether you can create a project variable depends on your role in that project. If the plan does not include variables, the screen tells you to upgrade.
For what an organization is, refer to Duaer organizations.
Create a variable
- On Variables, select Add variable.
- Enter a Key and a Value. A key is at most 50 characters; a value is at most 1000. A new key may use letters, numbers, and underscores, and it cannot start with a number—a leading number breaks the $vars.key dot form.
- When you create from the overview, choose Scope: Organization covers the whole organization, and picking a project limits it to that project. Creating from a project page sets the scope to that project.
- Select Save.
Edit or delete a variable
- On Variables, hover the row you want to change.
- Select Edit or Delete.
Use a variable in a workflow
Expressions and the JavaScript Code node both read it:
{{ $vars.api_host }}
$vars.api_hostThe first line is an expression in a node parameter. The second is a Code node. The key is the Key you saved.
Questions
How do you read a Duaer variable in an expression?
In Duaer, write $vars.key. Put it inside {{ }} in an expression. In a JavaScript Code node, write $vars.key directly. Every value is a string. A missing value is undefined, and the run does not fail for that.
Which Duaer variable wins when an organization key and a project key match?
A Duaer organization variable is readable across the organization. A project variable is readable only in that project’s workflows. The project value overrides the organization one. A run cannot change a variable—edit it on Variables.
In this section
Transform data with expressions in Duaer
Use expression transformation functions anywhere expressions are supported in Duaer. When you only reshape fields, prepare them in Edit Fields (Set) first.
ExpressionsUse built-in methods and variables in Duaer
Duaer's built-in methods and variables for working with data in expressions. The Code node runs plain JavaScript and native Luxon.
ExpressionsUse convenience methods in Duaer expressions
In a Duaer expression, use $json for the current item, $("Node name") for an earlier node, and $now and $if() for time and conditions.