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.
This helper is available in the Summer ’26 release of Marketing Cloud Next (API version 67.0).
| 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. |
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.
This example looks up a property in an object.
The function returns the value of the name property in the user object.
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.
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).
This example uses the loop index to access the previous item.
This example looks up a property name from the root context.
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.