+ Start a Discussion
Ker DeveloperKer Developer 

Apex Event trigger cannot handle batch operations on recurring event

Hello , 

 

We are trying to make an update for 6000 events with Data loader But I got this error : 

Apex Event trigger cannot handle batch operations on recurring events.

 

 

I updated my trigger to consider only non reccurent events by making this : 

 

Best Answer chosen by Admin (Salesforce Developers) 
APathakAPathak

Hi,

The event trigger cannot handle the batch operation on recurring events. Make sure that this trigger doesnt receive a batch containing more than 1 recurring type of events. This handling needs to be done outside the trigger .

 

Make batch size of data loader as 1. Then load the records.

 

If there are large number of records and its taking much time then the recurring records can be separately loaded with batch size as 1 and the normal event records can be inserted with greater batch size.

 

 

All Answers

Ker DeveloperKer Developer
trigger EventAfterUpdate on Event (after update) {
	if (PAD.canTrigger('TR003UpdateEventDateToBU.cls')){
    PAD.myLog('Task After Update <<< run by ' + UserInfo.getName());    
        
    List<Event> lstEvt = new List<Event>();
    
    for (Event evt : Trigger.new)
    {
    	if((evt.IsRecurrence ==false && evt.RecurrenceActivityId==null)||(evt.IsRecurrence ==true && evt.RecurrenceActivityId!=null))
    	{
    		System.debug('eeeeee+1'+evt.IsRecurrence);
		    	if (evt.WhatId!=null &&evt.Statut__c !='Terminé')
		    	{
		    	   lstEvt.add(evt);
		    	}
    	}
    }
    if (lstEvt.size()>0){
    	
    PAD.myLog('Nb of tasks  to treat:'+lstEvt.size());
    TR003UpdateEventDateToBU.UpdateLastEventDateToBU(lstEvt); 
    }
    PAD.myLog(' TR003UpdateEventDateToBU.UpdateLastEventDateToBU END'); 
    PAD.logLimits();
  } 
  
  
  
  //compteur des visites pour le PAC_Cible
  	List<Event> eventRToUpdate = new List<Event>();
  	List<Event> eventPToUpdate = new List<Event>();
  	System.debug('\n\n\n\n\n\n\neventOld: '+trigger.old);
  	System.debug('\n\n\n\n\n\n\neventOld: '+trigger.new);
  	for(Event e:trigger.new)
  	{
  		
  		if((e.IsRecurrence ==false && e.RecurrenceActivityId==null) ||(e.IsRecurrence ==true && e.RecurrenceActivityId!=null))
  		{
  			System.debug('eeeeee+'+e.IsRecurrence);
		  		if
		  		(e.Statut__c == 'Terminé' && e.Statut__c != trigger.oldMap.get(e.id).Statut__c )
		  		{
		  			//|| (e.Visite_realisee__c != trigger.oldMap.get(e.id).Visite_realisee__c && e.Visite_realisee__c == true)){
		  			eventRToUpdate.add(e);
		  		}
		  		if(e.Statut__c != 'Terminé' &&  trigger.oldMap.get(e.id).Statut__c == 'Terminé')
		  		{
		  			//operation inverse
		  			eventPToUpdate.add(e);
		  		}
  		}
  	}
  	
  	PACFonctions.visitesRealisees(eventRToUpdate,true);
  	PACFonctions.visitesPlanifiees(eventPToUpdate,true);

}

 


Ker Developer wrote:

Hello , 

 

We are trying to make an update for 6000 events with Data loader But I got this error : 

Apex Event trigger cannot handle batch operations on recurring events.

 

 

I updated my trigger to consider only non reccurent events by making this : 

 


 

APathakAPathak

Hi,

The event trigger cannot handle the batch operation on recurring events. Make sure that this trigger doesnt receive a batch containing more than 1 recurring type of events. This handling needs to be done outside the trigger .

 

Make batch size of data loader as 1. Then load the records.

 

If there are large number of records and its taking much time then the recurring records can be separately loaded with batch size as 1 and the normal event records can be inserted with greater batch size.

 

 

This was selected as the best answer