Google adds

Deletion of parent object, the child object automatically be deleted

 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

MDR

 <!-- Include html2pdf library --> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min....