Issue:
Below is a part of my class for updating Activity Count fields. I want to only select the id's from closed Tasks and also closed Events. I have no clue why my two lists below give me the "Compile Error: expecting a colon, found 'system.now'":
List leadsWithClosedTasks = [select id,Lead_Activity_Count_Closed__c,(select id, Status from Tasks where Status = 'Completed'), (select id, EndDateTime from Events where EndDateTime >= system.now())from Lead where Id IN : Leadids];
List leadsWithClosedTasks = [select id,Lead_Activity_Count_Closed__c,(select id, Status from Tasks where Status = 'Completed'), (select id, EndDateTime from Events where EndDateTime >= system.now())from Lead where Id IN : Leadids];
What we need:
We need to select the just the id's of the "Closed" Tasks and ALSO "Closed" Events and also vice versa for Open Tasks and Events. Selecting Closed & Open Events is not working for some reason? Does anyone know how to do this?
Thank you ahead of time.
//update all of the Leads with the number of Closed Tasks and Closed Events
List<Lead> leadsWithClosedTasks = [select id,Lead_Activity_Count_Closed__c,
(select id, Status from Tasks where Status = 'Completed'), (select id, EndDateTime
from Events where EndDateTime >= system.now())from
Lead where Id IN : Leadids];
List<Lead> leadsUpdatableClosed = new List<Lead>();
for(Lead Lclosed : leadsWithClosedTasks){
Lclosed.Lead_Activity_Count_Closed__c = Lclosed.Tasks.size();
leadsUpdatableClosed.add(Lclosed);
}
if(leadsUpdatableClosed.size()>0){
update leadsUpdatableClosed;
}
//update all of the Leads with the number of Open Tasks and Open Events
List<Lead> leadsWithOpenTasks = [select id,Lead_Activity_Count_Closed__c,
(select id, Status from Tasks where Status != 'Completed'),(select id, EndDateTime
from Events where EndDateTime < system.now()) from
Lead where Id IN : Leadids];
List<Lead> leadsUpdatableOpen = new List<Lead>();
for(Lead Lopen : leadsWithOpenTasks){
Lopen.Lead_Activity_Count_Open__c = Lopen.Tasks.size();
leadsUpdatableOpen.add(Lopen);
if(leadsUpdatableOpen.size()>0){
update leadsUpdatableOpen;
}
Thank you everyone.