You need to sign in to do that
Don't have an account?

updateleadstatus
Hi all
When I am execute this Trigger I am getting an error : Variable does not exist: l.id at line 38 column 43
Trigger 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;
}}
}
When I am execute this Trigger I am getting an error : Variable does not exist: l.id at line 38 column 43
Trigger 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;
}}
}
Hi karunakarreddy,
syntax is not correct here it seems...can u try with the following ?
There are couple of things to be notified in the above trigger.
- There is no need to use Aliases in the SOQL query unless you need to group the data.
- DML statements cannot be in for loops as there maybe a chance of hitting Governor limits.
Please find below modified trigger:Let us know if that helps you.
Best Regards,
BALAJI
The error is at line no: 26 near the for loop. It is terminated by a semicolon(;). So the execution stops there and not going forward. Remove the semicolon and try to save the code. You will get it executed.
Thanks.
Swetha
When I am execute the above Trigger I am getting same error
Error: Variable does not exist: l.id at line 28 column 45
Error: Variable does not exist: whoid at line 10 column 31
please find the screenshot
Could you please save the code in developer console. And The trigger is on Task object. Have you created the trigger under task object. Try it once in developer console..
Thanks
in the developer console also it will not working
Try deleting the existing trigger in your org and create a new one with same above code and also check the version.