Select an index of a message array

To select an array entry, here are the three (3) ways:

  • Directly indexing to a specific entry

  • Selecting the first matching entry for a defined condition

  • Selecting the last matching entry for a defined condition

Selecting an array entry

As part of the customized attribute mapping, the selector will choose the first array entry with matching criteria and selectorLast will choose the last array entry with matching criteria. Each option is described in detail in the following definition table:

Option

Description

index

Allows you to indicate which value in a sequence you want to use.

Specifying a negative one (-1) indicates that the last array entry should be selected. Other negative values are ignored.

Example: (5) – selects the 5th item (-1) – selects the last item, regardless of array length

Example:

Folder<event>

Array<participants> [2]

[0]: Str<purpose> = customer ; Str<address> = 5551234 ; Str<name> = Bob

[1]: Str<purpose> = agent ; Str<address> = 5556789 ; Str<name> = Charlie

If we want to extract out the address from index one (1) from the participants array, the extraction syntax is

event.participants(1).address which results in '5556789' being tagged to the attribute.

To extract the address of the last participant, regardless of array length, use:

event.participants(-1).address

selector

Use the selector syntax for a given entry index into an array that can be dynamically chosen based on a field within the array. Assuming a data structure as follows:

Example:

Folder<event>

Array<participants> [2]

[0]: Str<purpose> = customer ; Str<address> = 5551234 ; Str<name> = Bob

[1]: Str<purpose> = agent ; Str<address> ; Str<name> = Charlie

If we want to extract out the customer address field, the extraction syntax is

event.participants(selector:purpose=customer).address

selectorLast

Allows you to indicate a specific array entry based on a key-value criteria provided. The key and value are separated by the equals (=) character.

The 'selectorLast' will choose the last array entry with matching criteria.

Example:

Folder<event>

Array<participants> [4]

[0]: Str<purpose> = customer ; Str<address> = 5551234 ; Str<name> = Bob

[1]: Str<purpose> = agent ; Str<address> = 5556789 ; Str<name> = Charlie

[2]: Str<purpose> = queue ; Str<address> = 8888 ; Str<name> = first_queue

[3]: Str<purpose> = queue ; Str<address> = 9999 ; Str<name> = second_queue

If we want to extract out the address field of the last queue, the extraction syntax is

event.participants(selectorLast:purpose=queue).address which results in '9999' being tagged to the attribute.

Map attributes to an adapter

Attribute external name syntax

Limitations of attribute mapping