Pattern: Reference a Variable Within a Variable ({{lookup this field}})
Occasionally you may have a need to reference a field within a field (variable within a variable). The following syntax allows you to do so:
{{lookup this your-field-reference}}
What we're saying above is that your-field-reference
is actually a second field reference name, and we want to reference the second field's value.
See the attached workflow as an example, which has four workflow-level, single-choice-type, required fields. Emphasis below on the selections made at run start:
Entity: 1, 2, 3
, 4, 5
Number: 123, 456
, 789
Written Number: One Two Three, Four Five Six, Seven Eight Nine
Pick a Number: 1, 2
, 3, 4, 5, 6, 7
Say for example that based on the Entity, we infer we should use the Number (number) or Written Number (written-number) attribute, via a Tables: Look up data in a column step. If we select entity 3, we would expect the value number
to come back in a referenceable field: output-field-prefix--attribute-field-reference-name.
The Number we selected above at run start is 456
, which is a column in the below table. Again using Tables: Look up data in a column, for the Lookup column name parameter, we can use the following:
{{lookup this output-field-prefix--attribute-field-reference-name}}
Our choice for Pick a Number was 2
. We want to return the corresponding Color as a referenceable field, which for these selections will return Blue
.
Note that on import, in your Entity Attribute Table, you'll need to enter number
or written-number
in the Attribute Field Reference Name column.