I am using Flow for this. I have a list of potential customers listed in a custom object which is a related list to an Opp. The list could have the same company listed under different names, but with the same "Company ID". So there might be CompanyA with the CompanyID of 00111 and a CompanyB with the CompanyID of 00111 as well. Since they are both the same CompanyID I would only want to create one new Opp.

How can I create a collection upon the save of the main Opp to look all of the list up, but only have one entry for each CompanyID ?

I'm thinking of other ways of doing it like to just create the new Opp (with a custom field of CompanyID populated) - and then loop around the collection and check to see if there is already an Opp created for the CompanyID in the 2nd record - but would that work ? It seems like it wouldn't work because the newly created Opp record probably won't get seen when doing the lookup in the loop.

It would be a simple problem if I could just create a collection that only had one record per CompanyID. But I can't figure out how to do that...?

1 Answer 1


Thinking out loud. I would use a second collection of Company IDs called 'processedCompanyIDs' that is initialized as an empty collection. Each time you add an Opportunity to your 'opportunitiesToCreate' Collection, add a cooresponding entry into this collection. Check the collection for the ID each time before adding another Opportunity to your collection for creation.

1 - Get list of Potential Customers
2 - Loop List of Potential Customers
For each:
--IF (Company ID is in IDs Collection)
----Skip to next Potential Customer
----Add Opp to Opportunities Collection
----Add Company ID to IDs Collection
End Loop
3 - Create Record Element using Opportunities Collection

Does that work?

  • I think your method probably works. That's probably the way to go. Thank you very much....I'll let you know ;-)
    – Zoom_v
    Sep 28, 2022 at 13:06

You must log in to answer this question.

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