Extracts a specific field from each object in a list, returning a list of those field values. It supports both simple arrays and complex object structures.
Availability
This helper is available in the Winter ’26 release of Marketing Cloud Next.
Syntax
{{map list fieldName}}
Parameters
| Parameter | Type | Description |
|---|---|---|
list |
Array | Required. The list of objects to map. |
fieldName |
String | Required. The field to extract from each object. If the field doesn’t exist in an object, that object is skipped. |
Return Value
The function returns a new list containing the values of the specified field from each object in the input list. If the specified field isn’t present in an object, that object is skipped. If a parameter is missing or an element in the list isn’t a valid map, the function throws an exception.
Usage Examples
This example shows how to use the map function to extract the age field from each object in the list.
myList = [
{
"name": "D’Angelo",
"country": "Sweden",
"age": 30
},
{
"name": "Miguel",
"country": "Canada",
"age": 25
},
{
"name": "Lakshmi",
"country": "United States"
}
];
{{map myList "age"}}
The function returns [30, 25].
Chaining with Other Functions
You can chain the map function with other functions such as filter, sort, and flatten.
myList = [{"name": "D’Angelo", "age": 24}, {"name": "Miguel", "age": 27}, {"name": "Lakshmi", "age": 26}];
{{map (filter myList "age" ">" 25 "number") "name"}}
The function returns ["Miguel", "Lakshmi"].
Complex Object Structures
With complex nested objects, use the flatten function to flatten the nested objects before you map the values, as shown in this example.
myList = {
"orders": [
{
"items": [
{"name": "Reticulated Widget", "price": 100},
{"name": "Quantum Toaster", "price": 200}
]
},
{
"items": [
{"name": "Retro Encapsulator", "price": 300}
]
}
]
};
{{map (flatten (map myList "items")) "price"}}
The function returns [100, 200, 300].