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?