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.

images/download/attachments/78256106/image2022-9-28_10-16-31-version-1-modificationdate-1664352991111-api-v2.png

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

  • Option unchecked (default): Result values of the 'List' type are taken into account directly, i.e. as an entry of the 'List' type, in the return value

  • Option checked: For result values of the 'List' type, the contained entries are 'resolved', i.e. considered as 'independent' entries in the return value.

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]]
A configuration for the Value to collect parameter is omitted, so that the entries are 'collected' directly (see below).

  • As a rule, the pair of coordinates should also be kept together in pairs in the result. The Collect values resolver does this if the option Join collections is unchecked (default).

  • If the option Join collections is checked, then the return value in the specific case gives the longitude and latitude alternately in a common list level: : [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

  • Option unchecked (default): the return value lists all result values (except $null values) in the order of the processed entries from the input value.

  • Option checked: The result values for the return value are 'collected' internally as a set, which by definition contains only 'unique values'. If the same result value occurs repeatedly, the duplicates are effectively 'suppressed'.

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).

  • If the option Unique values is checked and no Value to collect is configured, then the return value in JSON notation is: [32,16,-4,8]

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).

  • If the total input value is 'no value' $null (see 'Special cases' above) or an 'empty list' (without entries), then value resolvers in the Value to collect parameter are not processed.

  • If the list in the input value contains 'no value' $null as an entry, then no entry is added to the list in the return value and value resolvers in the Value to collect parameter are not processed.

  • If no value resolver is configured for the Value to collect parameter, entries from the input value (except $null values) are processed directly as result values.

  • If value resolvers configured for the Value to collect parameter return $null as the result value for an entry from the 'no value' input value, then no entry is added to the list in the return value.

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:

  • The Direct line items value resolver returns a list of all direct line items in the shipment with the 'default' Line item type as the input value for the Collect values value resolver chain.

  • In the Value to collect parameter, the 'Loading aid.Type' (loadingAid.type) is determined for each line item by the Object property value resolver.

  • The Unique values option was checked so that in the return value each used loading aid type is included only once.

images/download/attachments/78256106/image2018-12-11_16-8-13-version-1-modificationdate-1628600090088-api-v2.png

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).

images/download/attachments/78256106/image2018-12-11_16-25-0-version-1-modificationdate-1628600090082-api-v2.png

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.