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

Trigger is not working when update using dataloader
Hi,
As I am able to update on single records but not working when its on bulk.
here is my code///
public class UpdateActivityHistoryCallCount {
//To update the Count of Activity History in Lead object
public static void countActivityHistoryOnLead(list<Task> newTaskList,list<Task> oldTaskList){
set<Id> LeadIds=new set<Id>();
list<Lead> leadList=new list<Lead>();
Map<Id, String> error = new Map<Id, String>();
if(trigger.isInsert || trigger.isUnDelete || trigger.isUpdate){
for(Task tsk:newTaskList){
if(string.valueOf(tsk.WhoId).startsWith('00Q'))
LeadIds.add(tsk.WhoId);
}
}
if(trigger.isDelete || trigger.isUpdate){
for(Task tk:oldTaskList){
if(string.valueOf(tk.WhoId).startsWith('00Q'))
LeadIds.add(tk.whoId);
}
}
if(LeadIds.size()>0){
for(Lead l:[select id,(select id,subject,Due_Date__c,CreatedDate
from tasks where (subject='Call' and status='Completed'
and Due_Date__c < Today) or (subject='Call' and status='Completed' and Due_Date__c = null) )
from lead where id in :LeadIds limit 50000])
leadList.add(new lead(id=l.Id,Call_count__c=l.tasks.size()));
}
Database.SaveResult[] results= database.update (leadList,false);
system.debug('@@@@' +results);
}
}
Thanks
As I am able to update on single records but not working when its on bulk.
here is my code///
public class UpdateActivityHistoryCallCount {
//To update the Count of Activity History in Lead object
public static void countActivityHistoryOnLead(list<Task> newTaskList,list<Task> oldTaskList){
set<Id> LeadIds=new set<Id>();
list<Lead> leadList=new list<Lead>();
Map<Id, String> error = new Map<Id, String>();
if(trigger.isInsert || trigger.isUnDelete || trigger.isUpdate){
for(Task tsk:newTaskList){
if(string.valueOf(tsk.WhoId).startsWith('00Q'))
LeadIds.add(tsk.WhoId);
}
}
if(trigger.isDelete || trigger.isUpdate){
for(Task tk:oldTaskList){
if(string.valueOf(tk.WhoId).startsWith('00Q'))
LeadIds.add(tk.whoId);
}
}
if(LeadIds.size()>0){
for(Lead l:[select id,(select id,subject,Due_Date__c,CreatedDate
from tasks where (subject='Call' and status='Completed'
and Due_Date__c < Today) or (subject='Call' and status='Completed' and Due_Date__c = null) )
from lead where id in :LeadIds limit 50000])
leadList.add(new lead(id=l.Id,Call_count__c=l.tasks.size()));
}
Database.SaveResult[] results= database.update (leadList,false);
system.debug('@@@@' +results);
}
}
Thanks
This is the limitation of dataloader, you can use Import wizard instead