Browse documentation

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 region, a date, a data object, without being rebuilt for each. This is the workflow counterpart of a canvas's context variables.

Define a context variable

Context variables are edited from the workflow canvas top bar:

  1. Click Add context variable.
  2. Enter a Title. Titles are lowercase snake_case, for example my_variable, and must be unique (a duplicate shows This title is already taken).
  3. Choose a Type.
  4. Optionally add a Description, and for a Data Object type, pick the object it refers to.
  5. Click Confirm.

The available types are string, number, boolean, date, and data object. Variables appear as chips in the bar; drag them to reorder, or use the × to remove one. File-triggered workflows also carry a built-in File Received variable for the arriving file.

The Add context variable popover with a Title of isin, a Type of String, a Description, and a Confirm button.
Add a context variable: a snake_case title, a type, an optional description.

Supply values when it runs

A variable's value is provided at run time, in one of three ways:

  • Running by hand: the Configure Workflow Context dialog prompts for each variable, then you click Run Workflow.
  • On a schedule: a scheduler's Context Variables section supplies 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.
The Configure Workflow Context dialog prompting for the isin variable's value, with Cancel and Run Workflow buttons.
Running by hand: the Configure Workflow Context dialog asks for each value.

Use a variable in an action

Where an action takes a filter or a value, insert a variable instead of a fixed value: click the braces control (Use context variable) and type the token {{ context.my_variable }}. Spark fills in the value at run time. Because it's a text token, match the variable's title exactly. Context tokens are available in the actions that filter or load data, such as loading records, creating a record or task, and analytics filters.

An action's Filters with a value field in context mode holding the token {{ context.isin }}.
Use a variable in an action by typing its {{ context.… }} token into a value.

There's no default-value field on a 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 reference them by name in {{ context.… }} tokens.

Where to go next