You can use the Map function to convert a list to a new list by running a child Flow for each item in the list. For more for information about child Flows, see What is a Child Flow?.
For example, if you have a child Flow that converts numbers to text (1 to “1”), you can run that child Flow on a whole list at once using the Map function to go from
["1","2","3","4","5"]. Similarly, you might use Map to generate a list of row subtotals from a list of spreadsheet rows (objects). With the Map function, the output list always has the same number of items as the input list.
- Defining a Child Flow with the Map Function
- Filling Out a Map Card
Defining a Child Flow with the Map Function
To use this function, you need a child Flow that takes a single item in the list and calculates the value to use for the new list. This child Flow gets called once for each item in the list.
Define fields on the event card that will be the inputs that help determine the corresponding value for the new list. At a minimum, you’ll need a field for the item from the list (which you can name whatever you want). Then build the rest of the child Flow, ending with a Return card that provides the value for the same position in the new list. If the new list will made up of items that are not type Object (e.g. numbers or text), then there should be a single return field of that type and its name doesn’t matter. If the new list will be a list of objects, then there should be several fields on the Return card: one for each of the keys of the object and the names of the fields must match the key names.
Filling Out a Map Card
Update the following input fields:
- List: The starting list
- Flow: The child Flow that is called once for each item in the list
- With the following values (dynamically generated): Here you will see a list of all of the inputs required by the child Flow. You can use these like normal input fields, or (for at least one of the inputs) you can click the arrow to the right of the input to choose Item to send the list item for that input to the child Flow. In some instance, you may also be able to select a specific path within an object instead of Item.
- Concurrency (number): Displays the number of items in the list to process in parallel. If it is important that the items are processed in sequence, use 1. Otherwise a higher number like 5 or 10 will cause your Flow to complete sooner.
The following output fields display:
- New list: Displays the resulting list after the child Flow has executed on each of the items. Set the type of _new list_ to match the value being returned by the child Flow, or to Object if multiple values are being returned.