You need to sign in to do that
Don't have an account?

Merge contacts on account
I need to know how can I detect a merge contact operation in triggers?
I've created a trigger that checks for a custom object record related to contact record and prevent the deletion of that custom object recordif it has certain status field value.
Now, when I try to merge 2 contacts, this operation somehow triggers a DELETE operation on related records (my custom object). And since I prevent the custom records to be deleted if they hold some status value, so Merge Operation fails ...:( ..
The hard part in understanding is that .. why would merge operation Delete records instead of Updating them with other updated Contact record value?
Hi,
When records are merged, the "master" record is updated and the other(s) are deleted. The ones that are deleted have a value in the "MasterRecordId" field. So you can check for that in a delete trigger.
I think merging contacts will merge the standard related records like activities but not custom objects - Is your custom object a master-detail on contact? That would explain the cascade delete effectI meant the MasterRecordId field on Contact.
Do you have any other triggers on Contact or your custom object which might be causing the delete ?
Ok now that u mentrioned .. yes actually I am preventing the delete of contact if it has any custom record in some status :( ..
so I guess that error is from the Contact delete .. so merge con6tact is delting the contact record and that record would be the Duplicate reocrd I intende to merge ?
Hi again,
is your trigger "before delete"? I'm betting that if you change it to "after delete", everything will be fine,
The reason being, the merge process will update the contact lookup fields after the "before" trigger fires, but before the "after" trigger fires.
Yes it before delete ... :( .. an after delete will not work for my app as it will allow deletion of contact in that case ....
Actually problem looks like merge wants to delete the duplicate contact and i am not allowing to delete contact if it is related to a custom record in particular status.