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
viktorVviktorV 

Handling merge / ondelete cascade on Contact + custom object

Hi,

 

I have a custom object, related to Contacts (lookup relationship, cannot use master-details because different reasons).

 

I'd like to handle delete and merge functions: when user deletes a contact, related custom object should be deleted as well ->

I've created a before delete trigger on contacts, worked well. (cannot use after delete, because contact reference disappears from custom object on delete)

 

I'd like to handle merge as well, so I need an if(triggerContact.MasterRecordId == null) expression for my delete trigger (so the merge could be done), but the problem is that MasterRecordId field is just getting value after delete, not before.

 

How could I solve this anomaly??

I'd appreciate any kind of idea..

Thank you,

Viktor