I'll post the short-version here, but it's still rather long and rambling- please do ask for more details and I'll try and oblige!
We want to merge a lot of duplicate contacts in Salesforce, however we have the Hubspot sync enabled. A basic test of merging contacts in Salesforce often led to problems because the "wrong" hubspot contact would survive- it appears in some instances that the email addresses that match between a SF & HS contact are the opposite ones to where the salesforce ID's on the hubspot contacts are. e.g.
SFDC 12345 foo@foo
HS "ABC" foo@foo SFID 67890
SFDC 67890 bar@bar
HS "DEF" bar@bar SFID 12345
If we just merge directly in SF, we end up with contacts getting removed, depending on the specifics. I narrowed this down to the theory that we need to really merge on both sides so as to ensure the "Salesforce ID" on the hubspot contact remains the correct one for the surviving record in Salesforce.
So, I wrote a simple commandline tool that takes in a csv of "primary/secondary" Salesforce IDs. For each pair, it establishes the related hubspot ID's and uses the API to run the merge command. So in the example above, if I wanted to merge 67890 into 12345 so 12345 survived, my tool would work out that Hubspot we need to merge ABC into DEF so DEF survives (as it has the 12345 salesforce ID property)
What I'm finding though, is after the merge (I turn off the sync, merge in Hubspot, then in Salesforce), the hubspot contact seems to generally end up with the wrong salesforce ID (67890 in this case) - when the sync next executes after being enabled, the contact is deleted as that ID no longer exists in Salesforce.
The documentation wasn't too clear on merging- it says that in general the most recent property survives; but also says that when linked to Salesforce, the "primary" is the one that keeps syncing. That suggests to me that the Salesforce ID of the primary (surviving) contact is the one that should stay. But that's not what seems to happen.
Ideas? If there's another way people have undertaken mass merges when also linked to SFDC, please shout.