Free Salesforce Developers Tutorials >

Chapter 8 - Apex DML and Database Methods >

Merge | APEX DML Standalone Statements

Merge | APEX DML Standalone Statements

What You’ll Learn


S2 Labs

Merge In Salesforce

To merge two or three records together, you need to use the merge statement.

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.
  • 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>

Salesforce Developer

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *