You need to sign in to do that
Don't have an account?
Anthony Zirilli 10
Bulkify Code (Too many SOQL queries error)
Hi there,
I just wrote this simple code to delete line item records when a checkbox "Delete Line Items" is true. The only problem is that the querry goes over the governor limits when doing bulk uploads. How would I rework this so that all Print Copy Line items associated with the Print Copy object are deleted when the "Delete Line Items" checkbox is true (which is located on the Print Copy Object). Thank you in advance.
Best,
Anthony
trigger DeletePrintCopyLineItem on Print_Copy__c (after update,after delete) {
List<Id>LstID=new List<ID>();
for(Print_Copy__c PrintCopy : Trigger.old){
List<Print_Copy_Line_Item__c> existinglineitems = [Select Id from Print_Copy_Line_Item__c Where Print_Copy__r.Delete_Line_Items__c=True];
delete existinglineitems;
}
}
I just wrote this simple code to delete line item records when a checkbox "Delete Line Items" is true. The only problem is that the querry goes over the governor limits when doing bulk uploads. How would I rework this so that all Print Copy Line items associated with the Print Copy object are deleted when the "Delete Line Items" checkbox is true (which is located on the Print Copy Object). Thank you in advance.
Best,
Anthony
trigger DeletePrintCopyLineItem on Print_Copy__c (after update,after delete) {
List<Id>LstID=new List<ID>();
for(Print_Copy__c PrintCopy : Trigger.old){
List<Print_Copy_Line_Item__c> existinglineitems = [Select Id from Print_Copy_Line_Item__c Where Print_Copy__r.Delete_Line_Items__c=True];
delete existinglineitems;
}
}
Please try below code and let me know.
Best Regards,
-Vivek
All Answers
Try with below code.
Replace Print_Copy__c with the relationship name from Print_Copy_Line_Item__c to Print_Copy__c .
Let me know if it helps
Please try below code and let me know.
Best Regards,
-Vivek