trigger orderreceived on Quote__c (after update,after insert) {
Profile pr = [select id from Profile where name='USA User'];
Set<id> QuoteId = new Set<id>();
for(Quote__c q:Trigger.new){
if(UserInfo.getProfileId()==pr.id){
if (q.Order_Received__c!= Null && q.Order_Received__c == true )
QuoteId.add(q.Id);
}
}
list<task> tasklist=[SELECT Id,whatId,whoid FROM Task where whatid=:Quoteid ];
for(task t: tasklist){
t.status='completed';
tasklist.add(t);
}
update tasklist;
}
ERROR:
execution of AfterUpdate caused by: System.FinalException: Cannot modify a collection while it is being iterated.
DML
s inside a loop(task update in your trigger)