Context variables
Declare named, typed inputs on a workflow and supply their values when it runs.
Context variables are named, typed inputs you declare on a workflow. You define them once, then supply values when the workflow runs, so one workflow can run against different inputs, a date, a portfolio, a file, a set of records, without being rebuilt for each. This is the workflow counterpart of a canvas's context variables.
Wherever a variable shows, in the editor, a step's card, the Workflows list or a run, it reads as {{ name }}, in purple, led by its type's icon.
Define a context variable
Context variables live at the left of the editor's toolbar:
- Click Add context variable.
- Enter a Title. Titles are lowercase
snake_case, for examplemy_variable, and must be unique (a duplicate shows This title is already taken). - Choose a Type.
- For a Record variable, pick its Data object.
- Optionally add a Description.
- Click Confirm, then Save the workflow.
Each variable shows as a chip in the toolbar, as {{ name }} with its type icon; hover it to see its type (and a Record's data object), and use its × to remove it.
Variable types
The Type list offers these, in this order:
| Type | Each run supplies |
|---|---|
| Date | A date, or a relative one (see below) |
| String | A piece of text |
| Number | A number |
| Boolean | True or false |
| Record | One record of the data object you chose when defining the variable |
| Data Object | A data object and, optionally, filters on it, picked when the run starts |
| File | A file from the workspace |
A workflow that starts with a File Received trigger also carries a built-in File Received variable, the file that arrived.
Data Object variables
A Data Object variable lets each run choose what to work on. You don't pick a data object when you define it; instead the run dialog (or a scheduler) asks for a data object, then for filters on it, the same way a step's Data Object and Filters fields do. The run starts once a data object is picked, and the run's value reads as the data object's name and how many filters narrow it.
Pick the variable in a Load Records step's Data Object list, where variables are listed above the tables. The step then loads that data object with the run's filters applied ahead of its own, up to 10,000 records, and says so in its output if it stops there. Choosing the variable clears filters and a view the step had set for another data object.
A run or a schedule can only name a data object its user is allowed to read.
File variables
A Load File step's File field opens a menu listing the workflow's File variables under Context variables, then Select a file under Files. Pick a variable and the step loads whichever file each run supplies. See Read a CSV or Excel file.
Supply values when it runs
A variable's value is provided at run time, in one of three ways:
- Running by hand: after Run workflow?, the Configure workflow context dialog asks for each variable. Fill them in, then click Run workflow.
- On a schedule: the scheduler holds the values. You can enter several values for a variable to fan the schedule out into a batch of runs, one per combination. See Scheduling.
- From another workflow: an Invoke Workflow action maps the previous action's output columns onto this workflow's variables. See Invocation.
A Date value can be relative to the day the run starts: Trigger date (today), Trigger date - 1 day (yesterday), or a number of days before (T - N days), which is what you want for a schedule that should always look at the previous business day.
The values a run was given show under the workflow's name on its row in Executions, and at the top of the run's page.
Use a variable in an action
Where a step's field can take a variable, a braces button, Use a context variable, sits beside it:
- Click the braces. In a file field such as Load File's, a Context variables menu lists the workflow's variables; in a filter value, the box switches to a text field that starts with
{{ context. }}, for you to complete with the variable's name. - Pick or type one. A picked variable shows as
{{ name }}and is filled in at run time. - To give the field its own value again, click the × beside it (Remove context variable).
Under the hood the field stores the token {{ context.name }}, which is also what you can type into a filter value. A step that reads a variable names it, as {{ name }}, on its card on the canvas.
There's no default-value field on a workflow variable, so every run needs a value, supplied by the run dialog, the scheduler, or the invoking workflow. Keep titles short and descriptive, since you pick them by name.