Key concepts
Data & mapping

Mapping arrays

7min
an array is a special type of item a simple array contains one or more text values a complex array contains one or more collections of the same type an example of a complex array is the email attachment the watch emails module returns an array of attachments for every email every attachment represents a collection that may contain a name, content, size, etc mapping an array's first element if you map the array's recipient name item, it will appear in the field like this the number between the square brackets is an index that determines which element of the array will be used leaving it empty defaults to the first element mapping an array's element if you wish to access another element, enter or map a value between the square brackets in the below example, enter 2 to select the second element mapping an array's element with a given key some arrays contain several collections with key and value items these are typically various metadata, attributes, etc the following example shows the output of the woocommerce > get a product module that contains the item meta data , which is an array of collections each collection contains the key item meta data id and the value item value the typical requirement is to lookup an element by its given key value and to obtain the corresponding value from the value item this can be achieved with a use functions docid\ efn1ajre8ityvlhd3x9hb employing a combination of the array functions docid\ k8nymrgqbg3l 8lnpx7wm and general functions docid\ pmt2j3ndx4b4bp51gxk6t functions the following example shows how to obtain the value of the value item of the element with key meta data id item value equal to 20642 the result of the formula will be "no" the detailed breakdown of the formula follows the 1st parameter of the map() function is the whole array item the 2nd parameter is the raw name of the value item to obtain the raw name, hover the mouse cursor over the item in the mapping panel all parameters are case sensitive even though in this particular example the item's label differs from its raw name only in capitalization, it is necessary to use the raw name, which is all lowercase value in contrast to the label value the 3rd parameter is the raw name of the key item the 4th parameter is the given key value because the map() function returns an array (as there could be more elements with the given key value), it is necessary to apply the get() function to get its first element the 1st parameter of the get() function is the result of the map() function the 2nd parameter is the element's index one see also our extract an item and/or its value from an array of collections video tutorial see also our extract an item and/or its value from an array of collections https //www youtube com/watch?v=w9cgdteppme video tutorial converting elements to a series of bundles arrays can be converted to a series of bundles using the flow control docid\ ncszyp3n o5a3r4cuqcel module the outputs from modules wrapped between an iterator and aggregator are not accessible beyond the aggregator module