Let us know so we can improve!
Handlebar Helper Function: Lookup
Dynamically access an object property or array element by specifying a variable. Unlike dot notation ({{object.property}}), which requires a literal property name, you can use lookup to determine the property name or array index at run time.
This function is based on the Handlebars.js lookup helper.
Availability
This helper is available in the Summer ’26 release of Marketing Cloud Next (API version 67.0).
Syntax
1{{lookup object key}}Parameters
| Parameter | Type | Description |
|---|---|---|
object | Object or Array | Required. The object or array to look up a value from. |
key | String or Integer | Required. The property name or array index to retrieve. |
Return Value
The return value has the same data type as the retrieved property.
If the key doesn’t exist or the index is out of bounds, the function returns undefined. An undefined property renders as an empty string.
Usage Examples
This example looks up a property in an object.
1{{lookup user "name"}}The function returns the value of the name property in the user object.
Dynamic Property Access
You can use a variable to determine which property to access. This example loops through the field names in the data object and performs a lookup on each one.
1{{#each fields}}
2 {{lookup ../data this}}
3{{/each}}Array Index Lookup
You can use this function to return an array element by index. This example returns the first element in the items array (the first element in an array is 0).
1{{lookup items 0}}Using Loop Index
This example uses the loop index to access the previous item.
1{{#each items}}
2 Previous: {{lookup ../items (subtract @index 1)}}
3 Current: {{this}}
4{{/each}}Accessing Root Properties Dynamically
This example looks up a property name from the root context.
1{{lookup @root propertyName}}Nested Lookup
You can chain multiple lookup operations together. This example looks up the value of category in the data object. In that result, it returns the value of the itemName property.
1{{lookup (lookup data category) itemName}}See Also
Let us know so we can improve!