function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MrBrianMrBrian 

Fast lookup in flow for unique values only

Hi there,

I am struggling to create filter criteria a Fast Lookup element in a Visual Flow that I can use in a loop to create some new records.

- I have a custom field on QuoteLineItem called "Group__c" that users can be assigned numeric values to group line items.
- I would like my Visual Flow to loop through each "Group" value and create a "Build Asset" for each group number, where custom objects can be listed.

For example, a quote is created for Item 1 and Item 2. Item 1 consists of A, B and C, and Item 2 consistesns of C, D, and E. The quote is created for six line items, three of which are in group 1 and three are in group 2. My flow, when run, would create 2 "Build Assets" (one for each Group), and then will place A, B, C, C, D, and E into the correct build.

The issue I am having is I can't figure out how to make a list or a fast lookup where the Group__c must be unique. Eg. I need to be able to select one from each group, or create a loop where we say "for each unique group value, create an object". Can this be done with a Flow? Or am I basically looking a trigger to get this sort of filtering? Or, is there another workaround?

Thanks!
YuriGarciaCaetanoYuriGarciaCaetano
Hi, MrBrian. I know it's been a while, but did you find any solution for this issue?
I am facing the same problem here =/
Unable to get/filter only exclusive IDs from an object through my loops.
MrBrianMrBrian
Hello, if using a collection variable, you can use a loop that for each loop element first removes all values from the collection, then adds it back once. In my case, I am looping through opportunity product dates to make a collection variable with only unique values.

Here is the loop:
User-added image

First, remove all values for the current variable in the loop:
User-added image

Then, add the value:
User-added image

I also have one last assignment that removes any null values in case there were some products without dates, but that will depend on your application. Hope this helps!
YuriGarciaCaetanoYuriGarciaCaetano
Hi, MrBrian.
Thanks a lot for introducing me to the operator 'Remove All'. I really didn't know about it.

I had to make a few adjustments in the logic you provided to fit in my requirements, but it does work nicely.
Now, I am going to add a decision to check if the collection I am comparing is null at that moment or not. If it's, I'll skip the removing duplicate assignment. You know, just to optimize the flow a bit.

Again, thanks for your help. Have a good one.