trigger onParentObjectDelete on CustomObject__c (before delete){
List<Id> idsToQuery = new List<Id>{};
for(CustomObject__c a: Trigger.old){
idsToQuery.add(a.id);
}
//query all child records where parent ids were deleted
ChildObject__c[] objsToDelete = [select id from ChildObject__c where ParentId__c IN :idsToQuery];
delete objsToDelete; //perform delete statement
}
No comments:
Post a Comment