Newer Version Available

This content describes an older version of this product. View Latest

merge()

Merge up to three records into one.

Syntax

Usage

Use this call to merge records of the same object type into one of the records, deleting the others, and re-parenting any related records. Each merge operation is within one transaction. A batch merge has multiple transactions, one for each element in the batch.

The only supported object types are Lead, Contact and Account.

The masterRecord field indicates which of the records is the master record that the others are merged into. You can use queryAll() to view records that have been deleted during a merge.

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.

The following limits apply to any merge request:
  • Up to 200 merge requests can be made in a single SOAP call.
  • Up to three records can be merged in a single request, including the master record. This is the same limit as the Salesforce user interface. If you have more than three records to merge, use the same master record in each request to avoid errors.
  • External ID fields cannot be used with merge().

To find all records that have been merged since a given point in time, you can use queryAll() with a SELECT statement similar to the following:

It is a recommended best practice to narrow your result set to the most relevant records by filtering on SystemModstamp.

Starting with API version 15.0, if you specify a value for a field that contains a string, and the value is too big for the field, the call fails and an error is returned. In previous versions of the API the value was truncated and the call succeeded. If you wish to keep the old behavior with versions 15.0 and later, use the AllowFieldTruncationHeader SOAP header.

Note

Sample Code—Java

This sample merges one account with a master account. It creates two accounts and attaches a note to the account to merge with the master. After the merge, it writes the ID of the account that was merged and the number of child records updated, which in this case is one because the note of the merged account is moved to the master account.

Sample Code—C#

This sample merges one account with a master account. It creates two accounts and attaches a note to the account to merge with the master. After the merge, it writes the ID of the account that was merged and the number of child records updated, which in this case is one because the note of the merged account is moved to the master account.

Arguments

This call accepts an array of MergeRequest objects. A MergeRequest object contains the following properties.

Name Type Description
masterRecord sObject Required. Must provide the ID of the object that other records will be merged into. Optionally, provide the fields to be updated and their values.
recordToMergeIds ID[] Required. Minimum of one, maximum of two. The other record or records to be merged into the master record.

Response

MergeResult[]