Map
You can use the Map function to convert a list to a new list by running a helper flow for each item in the list.
For example, if you have a helper flow that converts numbers to text (1 to "1"), you can run that helper flow on a whole list at once using the Map function to go from [1,2,3,4,5]
to ["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 helper flow with the Map function
-
Filling Out a Map Card
Defining a helper flow with the Map function
To use this function, you need a helper flow that takes a single item in the list and calculates the value to use for the new list. This helper 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 helper 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 (for example, 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
-
Helper Flow: The helper flow that is called once for each item in the list
-
Item to send the list item for that input to the helper flow. In some instance, you may also be able to select a specific path within an object instead of Item.
: Here you will see a list of all of the inputs required by the helper 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 -
: 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 helper flow has executed on each of the items. Set the type of new list to match the value being returned by the helper flow, or to Object if multiple values are being returned.