I am trying to tackle creating multi-touch campaign attribution using visual workflows and am running into a particular use case.

To look at all of the Campaigns that are related to the Opportunity, I have been able to create a collection of all campaigns associated to contact roles on the opportunity. What I would like to do now is create a new collection of records that only contains unique campaigns that will eventually be created as campaign influence records on the Opportunity.

Does anyone have any tips on how I can look at a collection and only add unique values to a new collection?

The process I'm wondering would work is the following:

1.Create a campaign member collection (CM1) that contains (Id, ContactId, OpportunityId, CampaignId) 2. Create a second collection of campaign member (CM2) records (that is blank) 3. Create a loop and assign a record from (CM1) to an SOVar 4. Have a decision within the loop that looks to see if the CampaignId is contained in CM2. If no, add to CM2. If yes, loop through next record.

I would then use CM2 to create Campaign Influence records and Fast Create them on the opportunity.

Where I am getting hung up is that on the Decision I can compare (using contains) CM2 to SOVar but I can't specify to look at the CampaignId. From the documentation, it appears the whole value (all of the fields) in the Collection needs to match the variable I am comparing it to.

Has anyone run into this before using a flow? It seems like I could break down a collection to just a list of CampaignIds and then build it up to a list of CampaignMembers related to the Opportunity but there are some obvious errors with trying to reassociate a Campaign with a particular contact in a collection unless you sorted the contact by created date.

Do I need to use contains with the whole record or can I specify a field in the collection variable?

Thank you!

  • I too think you have to compare the entire sObject. However, you may be able to easily get around this. If you create one collection with your unique sObjects, and one with just the unique ids, than you can match on the ids, and if the id isn't in the unique collection yet, then you can add the the item to both your sObject collection and your id collection. Just a crazy though, i hope it works for you. – Kasper Mar 14 '17 at 13:03
  • @Kasper I'll be trying this out today and see if it works. I'll let you know, Thank you! – Matthew Solomon Mar 15 '17 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.