You need to sign in to do that
Don't have an account?
Kyo
System Limit 101
System.LimitException: Too many SOQL queries: 101
Trigger.UpdateQLine: line 4, column 44
trigger UpdateQLine on Quotes_Line_Item__c (after update) { for(Quotes_Line_Item__c QL:trigger.new){ if(QL.isClosed__c == false){ Opportunities_Line_Item__c[] OPL = [Select Id ,UP1__c,Quantity__c from Opportunities_Line_Item__c Where Id =: QL.Opportunities_Line_Item__c Limit 1000]; for(Opportunities_Line_Item__c OL:OPL){ OL.Quantity__c = QL.Quantity__c; OL.UP1__c = QL.Unit_Price_For__c; } update OPL; } } }
The problem here is that you have nested a select statement inside the loop that is iterating the trigger.new records.
The trigger needs "bukifying" so that you only have a single soql query that pulls back all the affected records in one go.
Usually you'd have something similar to the following for this:
Depending on your code, you may need to put these into a Map so that you can retrieve them by Id.
You won't be able to change the limit, as this is a hard governor limit.
If you've moved the SOQL outside of the loop, its probably the update (which I didn't notice first time through). Rather than updating each record, store them in a list and update them in one go outside of the loop.
Thank you Bob.
Perfect!