Examples
Five practical examples covering each major collection operation type.
Example 1 — Filter: Active Customers Only
A workflow receives a list of all customers from a CRM query. Use filter to retain only those with an active subscription status before sending renewal reminders.
{
"node_type": "CollectionOperation",
"name": "FilterActiveCustomers",
"config": {
"operation": "filter",
"collection": "{@ output.GetAllCustomers.data }",
"expression": "item.subscriptionStatus === 'active' && item.emailOptIn === true"
}
}
result contains only customers who are both active and opted in to email. count tells the next Switch node how many emails to send. An empty result (count = 0) can be handled by a conditional branch to skip the email loop.Example 2 — Map: Extract Invoice IDs from Order Objects
A Loop node needs an array of IDs to iterate over, but the source data is an array of full order objects. Use map to project just the IDs.
{
"node_type": "CollectionOperation",
"name": "ExtractOrderIds",
"config": {
"operation": "map",
"collection": "{@ var.orders }",
"expression": "item.orderId"
}
}
// Input: [{ orderId: "ORD-1", total: 100 }, { orderId: "ORD-2", total: 200 }]
// Output result: ["ORD-1", "ORD-2"]
result is a plain string array of order IDs. The Loop node can iterate directly over output.ExtractOrderIds.result.Example 3 — Reduce: Sum All Invoice Line Item Totals
After processing a multi-line invoice, calculate the grand total by reducing the line items array to a single numeric sum.
{
"node_type": "CollectionOperation",
"name": "SumLineItems",
"config": {
"operation": "reduce",
"collection": "{@ var.lineItems }",
"expression": "acc + item.amount",
"initial_value": 0
}
}
// Input lineItems: [{ amount: 100 }, { amount: 250.50 }, { amount: 75 }]
// Output result: 425.50
result = 425.50. Store this in a variable for use in the PDF invoice template and payment node.Example 4 — Sort: Products by Price (Cheapest First)
A product recommendation workflow needs to present the cheapest in-stock products first. Sort the product array by unit price ascending.
{
"node_type": "CollectionOperation",
"name": "SortProductsByPrice",
"config": {
"operation": "sort",
"collection": "{@ output.GetProducts.data }",
"field": "unitPrice",
"direction": "asc"
}
}
result is the same array sorted from lowest to highest unitPrice. The Loop node that follows renders product cards in price order.Example 5 — Distinct: Deduplicate a Contact Email List
A mailing list assembled from multiple sources may contain duplicate contacts. Use distinct on the email field to ensure each recipient receives only one message.
{
"node_type": "CollectionOperation",
"name": "DeduplicateEmailList",
"config": {
"operation": "distinct",
"collection": "{@ var.allContacts }",
"field": "email"
}
}
// Input: [
// { name: "Alice", email: "alice@co.com" },
// { name: "Alice Smith", email: "alice@co.com" }, // duplicate email
// { name: "Bob", email: "bob@co.com" }
// ]
// Output result: [
// { name: "Alice", email: "alice@co.com" }, // first occurrence kept
// { name: "Bob", email: "bob@co.com" }
// ]