Is it possible to use a trigger to automatically merge records? Or is the best way to accomplish this is to update the values of the intended master record from the losing record, delete the losing record, and set the MasterRecordId?

1 Answer 1


It is absolutely possible to automatically merge leads using the Database.merge(SObject masterRecord,Id duplicateId) method, but you have to be very careful about how you choose which values will persist in the surviving record, as well as the order of execution for the delete and update statements. Any related records will also be re-parented to the master record.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .