+ Start a Discussion
Abdul Aziz KhatriAbdul Aziz Khatri 

To identify the Contacts in before delete trigger occurred as a result of Contact Merge

We are currently working on the requirement of using contact merge process. During the salesforce contact merge process, the system first deletes the duplicate contacts and then repoints the related records to the master contact that is to remain. As per the link below, the MasterRecordId is only available after the delete happens and after delete trigger.


We have a before delete trigger in our org that checks to see if a contact has related records as well as other conditions and based on that information, it allows the contact to be deleted or stops a user from deleting the contact. Our before trigger as it is currently written, stops the merge process. We are so far unable to find a way to identify within the transaction that the delete is occurring due to a merge so that we can handle merge process within the trigger. We are looking to see if someone might help with this tricky issue? We haven’t been able to identify something in the documentation of the merge process that will help us rewrite the trigger code.
ShashankShashank (Salesforce Developers) 
According to the documentation here, I'm afraid it is not possible to identify merge process in a before delete trigger. An alternative would be to create your own merge process to gain full control.