Use custom logic to determine how to remove duplicates from a list.
To use this function, you’ll need a helper flow that calculates the value that will determine if an item is unique or not. (For example, you may have a list of available volunteers but you only want one person for each combination of job specialty and primary language). The helper flow you specify will get invoked once for each item in the list and return a value for each item. After all of the items are assigned values, a new list is constructed with only one item for each unique value.
Define fields on the event card that will be the inputs that are required to determine the unique value. Typically you will include a field for the item of the list, i.e. if the list is a list of text then one of the inputs should be a string. You can also include as other inputs whatever your Flow will need to calculate the sort value. If you need to know the position of the current item within the list, use the “Index” field from the Context section of the helper flow card. Then build the rest of the helper flow, ending with a Return card that returns a single value. The name for the value on the Return card doesn’t matter. Save the Flow and turn it on.
Now go back to the Unique Custom card, input the list you want to remove duplicates from, and then select the Flow you just built. The inputs will auto-populate, then you can map data into them. To map an input to accept each item of the list, click in that field and you will see a drop down that includes Item – select that. Or if your list is a list of objects, you may also see the schema of the object, i.e. the keys that it contains, and you can also build your helper flow to accept those as inputs. In addition, you can drag in outputs from previous cards in the Flow – in that case, the same value will be used for each item in this list.
list: The input list that contains duplicates you want to remove
flow: The helper flow that will be called once for each item in the list
with the following values (dynamically generated): The inputs defined by the helper flow – these will populate after you select the helper flow using the Choose Flow dialog
concurrency: 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.
- list: The output list that contains only one item for each unique value returned by the helper flow. The type of output list should be set to match the type of the input list (for example, list of text or list of objects).
You have a list of text:
You create a helper flow that accepts a text input and returns the length of the text
For the text input to the helper flow, you click and choose "Item" from the dropdown
The output list will be:
["a","is","this"]– only one word of each length.