2

My flow below collect all due items of a custom object and I want to send an email to the owners concerned.

The flow below works fine, but if the owner has more than one item, the owner will receive several emails. But I want to send only one email to the owner, regardless of how many due items the owner have.

I only need at the end a list/collection of all owner which have >0 items.

Before |Record | Owner | |:-----:|:-----:| |A1 |Max | |B5 |Lucy | |A7 |Max | |H9 |John |

AFTER |Record | Owner | |:-----:|:-----:| |A1 |Max | |B5 |Lucy | |H9 |John |

enter image description here

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Oct 4, 2021 at 8:19

4 Answers 4

9

You can hangle that in the flow using sort, loop and assignment. I assume you have the list of the users in a Collection. I suggest doing the following:

  1. Sort the collection by username or any of the unique values on the user
  2. Loop through the collection.
  3. In the loop you first decide if your current loop item equals to variable previousUserId which is empty at the begging.
  4. If not, assign the current loop item to a new collection variable colFinalList.
  5. If yes, do nothing.
  6. Assign current loop item user ID to the previousUserId.
  7. At the end of the loop you have a list colFinalList without duplicates.

See the flow below

example flow

2

You could use the UnOfficialSF.com flow action - DeDupe Record Collection

Instead of all the looping in the other answers, this component invokes an Apex invocable class (provided) that takes a record collection as input and returns a de-duped record collection as output. Assumes there is a single field used as the dupkey.

Your flow thus has a single element. Part of the Record Collection package that is chock-o-block of good stuff

1

A simple approach I have used requires a single assignment element in a loop. In the assignment element you remove all instances of the loop variable from the collection and then add the loop variable to the collection.

assignment element

A bit more detail here: https://goravseth.com/creating-a-unique-collection-in-flow

In my case I only needed a unique set of Ids. I believe this will work for sobject collection also, but have not tested.

0

I don't know whether am right or wrong in this situation but I fulfilled my requirement by using Apex-Action to avoid duplicity from the collection variable.

Here is my flow : flow image

then I just passed my collection variable to the apex method to perform certain logic. which will return unique values (Lead LastName in my case). And logic is just to convert List to Set as Set contains only unique elements.

Here is my apex code : Apex Code

you can check my apex action input and output also :input and output of apex action

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .