You need to sign in to do that
Don't have an account?
How to bulkify these trigger
trigger Updateinvoicestatus on Line_Item__c (after insert,after update) {
trigger Updateinvoicestatus on Line_Item__c (after insert,after update) { Invoice_Statement__c[] I = new list<Invoice_Statement__c>(); for(Line_Item__c ln: trigger.new) { Invoice_Statement__c INV= new Invoice_Statement__c(id = ln.Invoice_Statement__c); List<Line_Item__c>Lnv=[select id,Name from Line_Item__c where Invoice_statement__c =:INV.id]; if(Lnv.size()==2){ INV.status__c='Closed'; I.add(INV); } if(lnv.size()==3){ ln.addError('You cant add more then five item'); } } Update I; }Plz give Suggestion
Here is the bulkify:
I'm not sure the name of relationship, So I assume it's Line_Items__r
Le
All Answers
Here is the bulkify:
I'm not sure the name of relationship, So I assume it's Line_Items__r
Le
In the below snippet you can relate the Trainingforce__Order_Line_Item__c with your Line_Item__c object and Trainingforce__Customer_Order__c with your Invoice_Statement__c object respectively.