function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dippan Patel 3Dippan Patel 3 

Apex Trigger to undelete the contact

Hi All, 

I have two contacts: Contact A and Contact B which are duplicates. Contact B has Custom Related Object (CRO) C. When Contact B is merged with Contact A, CRO C is moved to Contact A. Contact B is deleted. Instead of immediately deleting Contact B, I want to merge the two records, (moving CRO C to Contact A) and update values of Contact A. However, I want Contact B to remain. 

I want to write an apex trigger that can bring this deleted contact back or triggers any event that doesn't delete the Contact B. Or is there any other solution for this? 
GauravendraGauravendra
Hi Dippan,

One solution that cross my mind is you can create a before delete trigger on Contact.
Before deleting the record create a new record with same values.

Hope this helps.
Dippan Patel 3Dippan Patel 3
Thanks Gauravendra! I'll try this