martyychang / sf-automerge

Salesforce Auto-Merge Service for Apex
10 stars 4 forks source link

Campaign Members Concerns #4

Open danhowellnz opened 6 years ago

danhowellnz commented 6 years ago

Hi Marty,

Salesforce seems to have some basic support for merging campaign members when merging contacts/person accounts. It seems to delete the campaign members and then readd them after the merge. They all have new ids and createddates on the time of the merge.

This means they lose any custom fields attributed to them which is annoying. Do you have any ideas on how to support merge concerns for campaigns?

Could we find the merge concern values in the dynamic select and then store them in the mergeservice class and then update the new campaign member with the custom fields?

martyychang commented 6 years ago

This is interesting and a potentially complicated feature to implement, since the code would have to detect whether campaign histories were being consolidated or whether a "duplicate" campaign history entry was being merged. In this case, I feel the problem may better be solved by a trigger or workflow to correctly populate the Campaign Member fields when the final, persistent record is created.

Can you describe your specific scenario in a bit more detail? Perhaps explaining some of the custom Campaign Member fields you want to be correctly populated after a merge?

danhowellnz commented 6 years ago

I don't think a trigger would work as you have already lost the deleted campaign members (you could find in then in the deleted members). But that's messy. I think it's cleaner to capture their data before the merege.

An example field we have is Purchase_Date__c and EDM_List_Member_Id__c (which syncs with our edm programme).

At the moment those fields are removed after the merge and we have blanks :(

martyychang commented 6 years ago

@danhowellnz just curious, what EDM app do you use? And is Purchase_Date__c the date when a lead or contact purchased an event ticket?

danhowellnz commented 6 years ago

Our code is generic as it links into another api connection classes. Our EDM code is actually platform generic. So far works with Campaign Monitor and Mailchimp .

I don't think custom fields on a campaign member are unheard off. From my reading of documentation, salesforce takes the status of the responded member. We also store fields such as last added to a campaign to help with our generic marketing segmentation so it's nice to keep those values.

martyychang commented 6 years ago

@danhowellnz can you help me advance this issue by listing out some specific given-when-then scenarios that would be relevant to your use case? You can just write this out in plain English, and from there we can think about different ways to solve the problem.

danhowellnz commented 6 years ago

Ok is the sort of thing you are looking for?

Scenario: Different campaigns Given: two contacts are the member of different campaigns When: contacts are merged Then: both campaign members are kept and the campaign member for the lost campaign is updated to the new campaign

Scenario: Same campaigns Given: two contacts are the member of the Same campaign When: contacts are merged Then: The oldest campaign member is deleted, Salesforce chooses the member status that is responded Then: Any custom fields on the losing campaign member are not copied anywhere and are lost

martyychang commented 6 years ago

That's perfect @danhowellnz and for the second scenario, I'll interpret the requirement as we need to build something so that the custom field values are preserved somehow. So I'd rewrite the second scenario as...

Scenario: Same campaigns