Account Merge Trigger Execution Order

When account is merged, what’s the expected trigger order? Does the wining account get updated first or does the losing account get deleted? What happens when the child records are reparented?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

From the Apex Developer Guide

Triggers and Merge Statements

Merge events do not fire their own trigger events. Instead, they fire delete and update events as

Deletion of losing records

A single merge operation fires a single delete event for all records
that are deleted in the merge. To determine which records were deleted
as a result of a merge operation use the MasterRecordId field in
Trigger.old. When a record is deleted after losing a merge
operation, its MasterRecordId field is set to the Id of the winning
record. The MasterRecordId field is only set in after delete
trigger events. If your application requires special handling for
deleted records that occur as a result of a merge, you need to use the
after delete trigger event.

Update of the winning record

A single merge operation fires a single update event for the winning record only. Any child records that are
reparented as a result of the merge operation do not fire


For example, if two contacts are merged, only the delete and update contact triggers fire. No triggers for records related to
the contacts, such as accounts or opportunities, fire.

Trigger Order of Execution The following is the order of events when a merge occurs:

  1. The before delete trigger fires.
  2. The system deletes the necessary records due to the merge, assigns new parent records to the child records, and sets the MasterRecordId
    field on the deleted records.
  3. The after delete trigger fires.
  4. The system does the specific updates required for the master record. Normal update triggers apply.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x