Collection Operation
Apply LINQ-style operations to arrays and collections: filter, map, reduce, sort, distinct, count, first, last, and reverse.
What is Collection Operation?
The Collection Operation node provides declarative array manipulation without requiring custom code. It supports nine operations modelled on functional programming patterns (similar to LINQ or JavaScript Array methods). The expression field accepts JavaScript-like lambda expressions evaluated by the BizFirst expression engine, giving access to the item loop variable for per-element logic.
Supported Operations
| Operation | Description | Returns |
|---|---|---|
filter | Returns elements where the expression evaluates to true | Array (subset) |
map | Transforms each element using the expression | Array (transformed) |
reduce | Aggregates the collection to a single value using expression and initial_value | Scalar |
sort | Sorts by the specified field in direction order | Array (sorted) |
distinct | Returns unique elements, optionally by a field | Array (deduplicated) |
count | Returns the number of elements (optionally filtered by expression) | Integer |
first | Returns the first element (optionally matching expression) | Object or null |
last | Returns the last element (optionally matching expression) | Object or null |
reverse | Reverses the order of the array | Array (reversed) |
Key Capabilities
- JavaScript lambda expressions with access to the
itemvariable for per-element logic - Collection source can be a workflow variable, an expression, or a named node output
- Sort supports both ascending and descending on any field path
- Distinct deduplication on primitive arrays or by object field
- Reduce with configurable initial accumulator value for sum, product, concatenation, etc.
- Uses the IExpressionEvaluator engine — consistent with all other expression evaluation in BizFirst
Common Use Cases
| Scenario | Operation | How It Helps |
|---|---|---|
| Filter active customers | filter | Return only customers where item.status === 'active' |
| Extract order IDs | map | Transform an array of order objects to an array of item.orderId strings |
| Sum invoice totals | reduce | Accumulate acc + item.total starting from 0 |
| Sort products by price | sort | Sort on field: "price" with direction: "asc" |
| Deduplicate email list | distinct | Remove duplicate entries by field: "email" |
| Find first pending item | first | Return first element where item.status === 'pending' |