Collect values
Value resolver – Abstract
Purpose: Processes all entries (except $null values) of a list passed as input value with the optionally configurable value resolvers and lists the resulting values (except $null values) in the return value.
The Collect values resolver processes all entries (except $null values) of a list passed as input value with the value resolvers configured in the Value to collect parameter and lists the result values obtained in this way (except $null values) in the return value.
The Join collections option has the effect that the contained entries are processed as result values instead of a result value for the Value to collect, which is a list.
The 'list' for the result values is created as a set with the option Unique values, so each result value can be contained only once in the returned list.
Special cases:
If the input value is 'No value' ($null), the return value is also 'No value' ($null).
If the input value is an empty list ([]), the return value is also an empty list ([]).
If the input value is a value that is not 'No value' ($null) but also not a list, then this value is processed as if it were the only entry in a list.
If Value to collect returns a list containing $null values as the result value (for an entry from the input value), entries with the value $null will exceptionally appear in the return value if the Join collections option is set.
►NOTE◄ Without the Join collections option, result values that are lists will always appear (including any $null values they may contain) as entries with type 'list' in the return value.
Configuration
Parameter |
Effect |
Join collections |
Example: The input value is a list of static values (here: Geo-coordinates with decimal numbers for 'longitude' and 'latitude' as angular measurements) corresponding to the following JSON notation: [55.05,8.41],[47.27,10.18]]
►NOTE◄ The Join collections option only affects lists that are direct result values. If a list returned as a result value in turn contains entries that are lists, their 'grouping' as a list is retained. Entries from multi-level nested lists can be 'unified' if necessary by combining multiple instances of the Collect values value resolver. |
Unique values |
►IMPORTANT◄ The order of the result values in the return value does not reflect the processing order of the entries from the input value Example: The input value is a list of static integers corresponding to the following JSON notation: [32,16,8,-4,16,8] There is no configuration for the Value to collect parameter, so the entries are 'collected' directly (see below).
|
Value to collect |
Defines an optional value resolver or a concatenation of value resolvers that is applied to each entry of a list in the input value (or the complete input value if it is not a list).
|
Examples
Simple use case: Determine unique values for an object property
A list of loading aids types (see Loading aids) should be 'collected', which refers to at least one direct default line item of a shipment (see Shipments).
Configuration:
In the context of an event handling that receives the shipment to be examined as input value at runtime – e.g. within a Für jeden Eintrag wiederholen (Schleife) or Ausführen mit event action – the following value resolver chain is configured:
|
|
►NOTE◄ Based on the number of entries in the return value (via the length field), these settings can be used to evaluate, for example, how many different loading aid types are contained in the direct default line items. A rule that checks whether this number is >1 can thus also easily determine whether different loading aid types are used within the shipment or not.
More complex use case: Collecting values from selected instances for a multiple attribute on line item level
The following example uses two instances of the Collect values value resolver in a nested arrangement, for a more complex evaluation in the context of a shipment (see Shipments).
Specifically, a list of all unique 'barcode' values from barcode attributes found in direct line items of the 'Default' type in conjunction with a specification for the "barcode reference" (barcodeReference) field of the attribute is to be determined.
Configuration:
Within a Set value event action the list of 'collected' barcodes is assigned to a variable (BARCODES_MIT_REFERENZ).
On the right side of the assignment, the searched 'barcode' values are 'collected' via the following value resolver chain:
As in the previous example, the Direct line items value resolver returns a list of direct line items with the 'Default' item category as the input value for the outer Collect values resolver chain. This evaluates the value resolver chain defined in the Value to collect parameter on a per-item basis:
The Plural attributes (Resolver) value resolver returns a list of all instances for the plural 'barcode attribute' of the evaluated line item.
The Rule list resolver chain filters this list, to all instances of the attribute (see the Resolve all values as list option) whose field 'Barcode reference' (barcodeReference) is filled ('non-empty').
The inner Collect values resolver chain collects from the list of 'referenced' instances for the 'barcode attribute' for the values from the 'barcode' (barcode) field.
Therefore, the list of relevant barcodes for the evaluated line item is determined as the Value to collect in the outer Collect values resolver.
The barcodes collected per line item in this list are processed individually as result values by the outer Collect values resolver because the Join collections option is checked.
Since the Unique values option is also checked, any duplicates will be ignored. The return value contains each 'barcode' value exactly once.