ChildObject__c
ParentObject__c
Click to see the full question.
Relationship between ChildObject__c and ParentObject__c objects is Lookup relationship.
In case of lookup relationship if we delete the parent object record in child object only the relationship field value will be removed (child records won't be deleted).
But client has a requirement to delete the child object records. How to achieve this?
Write an apex trigger to achieve this functionality.
We should take before delete event. If we take after delete relationship will broke up b/w parent and child object records.
Trigger ParentTrigger on ParentObject__c(before delete) {
/*
Note:
-
For delete events only trigger.old and triggger.oldMap will be available.
-
trigger.old holds old versions of the records but if we mention that in SOQL query salesforce will automatically convert those records into ids.