function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TS-ITWTS-ITW 

Contact Merge via API Losing Data

We have a contact merge process outside of Salesforce that calls the Contact merge API.  We've seen several examples where this happens:
  • The last created Contact record is selected as the Master record (survivor)
  • The Contact record being deleted (merged into the Master) has data in FieldA, but the Master doesn't
  • After the merge, the data in FieldA on the Master is null
My understanding of the merge process is that it evaluates the field level last update date to determine which record to use data from.  However, wouldn't it also evaluate null vs. non-null?
Daniel BallingerDaniel Ballinger
I believe the merge() (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_merge.htm) API operation will, by default, only reparent records to the master record and then remove the merged records. It won't replace null field values in the master record with values from the non-master record(s).

From the documentation:
 
This call requires that you decide prior to the merge call if there are any field values from the non-master record(s) that should supersede the values in the master record. If so, the field names and their new values should be set in the masterRecord of the MergeRequest, similar to a call to update.
Apparently you can use the MasterRecord sObject to indicated which fields from the child should take precedence.