Referencing flow variables in a process flow

Introduction

The steps required to reference flow variables in a process flow can be summarised in two stages:

Stage 1: Define flow variables that can be used

Any flow variables that you want to reference from process flow shapes should be added as variables within the process flow settings. To do this, follow the steps below.

Step 1 Access the process flow that you want to update and make sure that you're switched to the required version.

Typically, you would update the draft version, then deploy changes when you are ready.

Step 2 Select settings (the cog icon) from the actions bar:

Step 3 Look for the variables section in the flow settings panel - for example:

Step 4 Click the add new variable button:

Step 5 In the name field, enter the name (i.e. the API parameter name) of this variable. For our example, the variable is named customerID:

Step 6 Click in the select a type field and select the data type for this variable:

Step 7 Enter the required value to be used wherever this variable is found in the process flow - for example:

Step 8 Add all required flow variables in the same way, then save changes.

Stage 2: Add references to defined flow variables

Having defined your required flow variables, they can be referenced from process flow connection shapes, wherever a variable field is present. So, if your connection shape is set to use an endpoint which requires/allows variables to be applied, you will see corresponding variable fields in the connection shape settings.

The example below shows how this works. A GET single order endpoint has been configured to expect a customerID variable, and then how this variable is surfaced in connection shape settings when this endpoint is used:

When defining variable values for a connection shape, you can enter a static value, or obtain values dynamically from a payload, or reference an existing flow variable. The steps below show how to reference a flow variable.

You can also reference flow variables in custom scripts (which means you can manipulate these values however you need) and also in field mapping transformations.

Step 1 In your process flow, access settings for the connection shape that you want to update with a flow variable:

Step 2 Look for the variables section in the settings panel - for example:

To use a flow variable here, the expected variable must correlate with a variable that you added in stage 1. Notice that the example above is expecting a Customer ID variable, which correlates with the customerID flow variable that we added in step 5 of stage 1.

Step 3 Use the syntax below to reference a flow variable:

{{flow.variables.variable}}

...where the variable element should be replaced with the name of the flow variable defined in process flow settings (stage 1). Using our example, this would be:

{{flow.variables.customerID}}

Step 4 Save changes. Now when this process flow runs, the value defined in process flow settings will be passed in for this variable.

Flow variable values can also be updated by custom scripts. For further information please see Referencing flow variables in custom scripts.

Last updated