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
West415West415 

Error: Too many batch retries in the presence of Apex triggers and partial failures

I'm using Data Loader to load in about 300 leads.  I have a trigger that runs before a lead gets inserted that checks to see if the lead exists based on a few fields on the Lead object.   If it does exist, it generates an error using addError().     Some of my data makes it in using Data Loader, but some of it doesn't and generates this error.

How can I load my leads in and avoid this error? 
R Z KhanR Z Khan
Can you post your trigger code? Seems like tis calling batch from trigger
West415West415
Sure.....
 
trigger MasterLeadTrigger on Lead (before insert, before update, before delete, after insert, after update, after delete, after undelete) {

	// before 
	if (Trigger.isBefore) {
  	
  	  if (Trigger.isInsert) {
     
        LeadAction.checkDuplicateLeads(Trigger.new);
      
      } 
    
  }
 
}
 
public static void checkDuplicateLeads(list<Lead> leads) {

		map<string,Lead> leadMap = new map<string,Lead>();
		map<string,Lead> leadCompanyMap = new map<string,Lead>();


		for( Lead newLead : leads ) {
			
			if(newLead.Company != null) {
				leadCompanyMap.put(newLead.Company,newLead);
			}

			
		}

       for( Lead lead : [SELECT Id, FirstName, LastName,Company 
											FROM Lead 
											WHERE Company in :leadCompanyMap.keyset() 
												]	) {
				if( leadCompanyMap.containsKey(lead.Company)) {
					leadCompanyMap.get(lead.Company).addError('A lead already exists with this information at this company');
				}
			
		}
}