Hi allWhen I am execute this Trigger I am getting an error : Variable does not exist: l.id at line 38 column 43Trigger updateleadstatus on Task(after insert,after update,after delete,after undelete){ public set<id>setids=new Set<Id>(); public List<Lead>LeadToBeChanged=new List<Lead>(); If(Trigger.isinsert || Trigger.Isupdate ||Trigger.Isundelete) { for(task t:trigger.new) { if(string.valueof(t.whoid).startswith('00Q')) setids.add('t.whoid'); } } If( Trigger.Isdelete ) { for(task t:trigger.old) { if(string.valueof(t.whoid).startswith('00Q')) setids.add('t.whoid'); } } If(setids.size()>0) { for(Lead l :[select l.id, l.task_Count__c,(select id from tasks where isclosed=false) from Lead l where id in:setids]); { LeadToBeChanged.add(new Lead(id=l.id,task_Count__c = l.tasks.size())); update LeadToBeChanged; }} }
I can able to save in my Dev org with the same code.Try deleting the existing trigger in your org and create a new one with same above code and also check the version.