I have a before delete trigger on account to prevent account deletion when certain related records attached(lookup relationship).This trigger also fires when accounts are merged and throws error when selected master record has related records. To avoid this is there any way to identify the merge operation in trigger context and bypass? Any suggestion is very much appreciated.


  • Hi Ved, the answer available in the below [link] (salesforce.stackexchange.com/questions/296132/…) Dec 14, 2021 at 10:01
  • @AnkaiahBandi Thank you for reply ! Do you mean this solution -Add a custom field, check box, Named: Merged? When merging records you can tick that custom field. This way to can flag records that were merged. On triggers you need to look at the value of the custom field to execute further logics around these records. I Can't think of any way to set the flag other than manually. 1. Manually set the flag on the master record which I am gonna select in merge interface. 2. Select the accounts and click "Merge". Is there any better way you think of to set the flag ? Thank you again in advance!
    – ved
    Dec 14, 2021 at 10:50

1 Answer 1


the solution I thought of was to run the matching rule again on the before-delete trigger, if a duplicate record is found, the system determines that it is currently a merge operation, of course, if it is not a merge operation, because the system still has the same record to delete one does not matter, so allow him to delete, do not have to judge whether there is a correlation with other Objects. You see if this is possible

  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Aug 5, 2022 at 1:26

You must log in to answer this question.

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