You can reference flow variables in field mapping transformations, using a custom string
transformation in the map shape.
Most typically, the custom string
transformation type is used to specify some custom text to be applied in a target field. For example, you might choose to add a particular sales rep's name to a reference
field for all orders being synced.
However, if your process flow is using flow variables, you can reference these in custom string transformations, instead of static text. When the process flow runs, the flow variable value is mapped to your given target field. If you later decide to update flow variables (either manually or via a custom script), those updates are mapped next time the process flow runs.
The steps required to achieve this can be summarised in two stages:
Any flow variables that you want to reference in field transformations 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've switched to the required version.
Typically, you would update the draft version, and 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 rep
:
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 Save changes.
Having defined your required flow variables, they can be referenced in custom string
field mapping transformations. Typically, this will be for scenarios where you want to map the output from a flow variable into a target field.
If you've added/updated a map shape before, you'll be used to selecting a source field and a target field. However, when we map a flow variable value to a target field, we don't select a source field - the custom string transformation is our data source.
Step 1 In your process flow, access settings for the map shape that you want to update with a flow variable:
Step 2 Click the add mapping rule option - for example:
Step 3 Click the add transform button:
Step 4 Click the add transform button:
Step 5 Click in the name field to access a list of all available transform functions, then select custom string:
Step 6 Move down to the custom string field and enter the following value:
...where the variable
element should be replaced with the name of the flow variable defined in process flow settings (stage 1) that you want to reference. Using our example, this would be:
For example:
You can also reference metadata variables in the same way, using the meta syntax:
[[meta.unique_key]]
Step 7 Accept your changes:
...then save the transformation:
Step 8 Now you can select a target field in the usual way - for example:
...then:
...then:
Step 9 Once your mapping is complete, the row should be displayed without a source field - for example:
From here you can save changes or add more mapping rules as needed. Next time the process flow runs, the value of this flow variable will be mapped to the target field.