You need to sign in to do that
Don't have an account?
Akash jena 3
Invalid character in identifier: Lead__cIds
trigger TaskCount on Task (after delete, after insert, after undelete, after update) {
Set<ID> Lead__cIds = new Set<ID>();
//We only care about tasks linked to Leads.
String leadPrefix = Lead__c.SObjectType.getDescribe().getKeyPrefix();
//Add any Lead ids coming from the new data
if(trigger.new!=null){
for (Task t : Trigger.new) {
if (t.WhoId!= null && string.valueof(t.WhoId).startsWith(leadPrefix) ) {
if(!Lead__cIds.contains(t.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t.WhoId);
}
}
}
}
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)
if(trigger.old!=null){
for (Task t2 : Trigger.old) {
if (t2.WhoId!= null && string.valueof(t2.WhoId).startsWith(leadPrefix) )
{
if(!Lead__cIds.contains(t2.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t2.WhoId);
}
}
}
}
if (Lead__cIds.size() > 0){
List<Lead__c> leadsWithTasks = [select id,Task_Count__c,(select id from Tasks) from Lead__c where Id IN : Lead__cids];
List<Lead__c> leadsUpdatable = new List<Lead__c>();
for(Lead__c L : leadsWithTasks){
L.Task_Count__c = Lead__cids.size();
leadsUpdatable.add(L);
}
if(leadsUpdatable.size()>0){
update leadsUpdatable;
//update all the leads with activity count
}
}
}
Set<ID> Lead__cIds = new Set<ID>();
//We only care about tasks linked to Leads.
String leadPrefix = Lead__c.SObjectType.getDescribe().getKeyPrefix();
//Add any Lead ids coming from the new data
if(trigger.new!=null){
for (Task t : Trigger.new) {
if (t.WhoId!= null && string.valueof(t.WhoId).startsWith(leadPrefix) ) {
if(!Lead__cIds.contains(t.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t.WhoId);
}
}
}
}
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)
if(trigger.old!=null){
for (Task t2 : Trigger.old) {
if (t2.WhoId!= null && string.valueof(t2.WhoId).startsWith(leadPrefix) )
{
if(!Lead__cIds.contains(t2.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t2.WhoId);
}
}
}
}
if (Lead__cIds.size() > 0){
List<Lead__c> leadsWithTasks = [select id,Task_Count__c,(select id from Tasks) from Lead__c where Id IN : Lead__cids];
List<Lead__c> leadsUpdatable = new List<Lead__c>();
for(Lead__c L : leadsWithTasks){
L.Task_Count__c = Lead__cids.size();
leadsUpdatable.add(L);
}
if(leadsUpdatable.size()>0){
update leadsUpdatable;
//update all the leads with activity count
}
}
}
Can you rename the variable from Lead__cIds to clds(without double underscore) or similar to see if it still throws the same error?
Related: https://salesforce.stackexchange.com/questions/246959/invalid-character-in-identifier-in-wrapper-class
Thanks