QUESTION:
We are using the HEDA model from Salesforce.org. Every time we attempt to merge duplicate Contacts we get a "Merge Call Failure" error:
- 2017-10-02T09:56:45-06:00,,"Merge Call Failure",,,,,,,"Msg:Record cannot be deleted because children records exist. Delete children first. StatusCode:54 Fields: "2017-10-02T09:56:45-06:00,Single Table Dedupe,"Dedupe complete",,,,,,,""
Why is this happening and is there a workaround?
ANSWER:
When merging Contacts in either DemandTools or DupeBlocker, the applications use the Salesforce merge code to perform the actual merge. The Salesforce merge code does not support merging in the HEDA model due to the complexity of the HEDA specific relationships. It seems that the HEDA triggers prevent some of the sub-objects on the non-master record from being moved (reparented) to the master record. The issues seem to be primarily with the Account Affiliations, but we have also seen issues with the Relationship objects as well (and there may be others as we did not test ALL the various sub-objects/possible HEDA configurations).
As a result when the Salesforce merge attempts to delete the non-master, the deletion is blocked, due to child objects still existing in the non-master Contact.
Users will see the SAME error, "Record cannot be deleted because children records exist. Delete children first.", if they try to merge the Contacts directly in the Salesforce User Interface using the "Merge Contacts" button in the Contacts tab, so this is not unique to our tools. If they cannot be merged in the Salesforce User Interface then they cannot be merged in our tools, DemandTools or DupeBlocker.
WORKAROUND:
Until this issue is addressed by Salesforce or Salesforce.org the best workaround is to manually move any sub-objects from the non-master contacts to the master contact, then perform the merge in DemandTools or DupeBlocker. This is tedious and needs to be done for each duplicate group, but it is the only way to get them to merge.
Some users in Salesforce posts have suggested disabling the HEDA triggers that are preventing the deletion of the problem sub-objects, however doing so will cause data loss as these objects HAVE NOT BEEN MOVED to the master record. So if you allow the non-master to be deleted (with these objects still attached) these objects will also be deleted!
We encourage any HEDA users who have come up with a different workaround that truly "merges" all the sub-objects to the master to post their findings and link back to this article. We at Validity are not experts on the HEDA model and there are lots of Settings/Customizations that can be tweaked. Hopefully, HEDA users, who are better versed in the model, can come up with a better workaround.
Users that run into this issue should also contact Salesorce.org directly to see if this issue is being addressed on their end. There were similar problems merging with the NPSP (Non Profit Starter Pack) that were addressed directly within Salesforce via a CUSTOM "Merge" button as part of that managed package. That only addressed merging within the Salesforce User Interface, but at least it is an option without having to manually move sub-objects then merge.