Example

List<Account> accList = [SELECT name FROM Account LIMIT 3];

Account a = accList[0];

Account b = accList[1];

Account c = accList[2];

List<Account> mergeList = new List<Account>();

mergeList.add(accList[1]);

mergeList.add(accList[2]);

merge a b; // for 2 records

merge a mergeList; // for 3 records

Note: Merge only works with Accounts, Leads and Contacts.

Note: You can merge 3 records at a time not more than that.

Different Merging Combinations:

  • sObject with sObject
  • sObject with List<sObject>
  • sObject with ID
  • sObject with List<ID>

Our Recent Blog

Share This Post