function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashu sharma 38Ashu sharma 38 

Trigger is not working when update using dataloader


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(trigger.isDelete || trigger.isUpdate){
            for(Task tk:oldTaskList){
            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);

Rahul Kumar DeyRahul Kumar Dey
This is the limitation of dataloader, you can use Import wizard instead