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
Dipen IshaniDipen Ishani 

ERROR: SubscriberUpdateTrigger: System.LimitException: Too many future calls: 51

Hi All

When updating 115 record through data loader,
i got this error message. 
ERROR: UpdateTrigger: System.LimitException: Too many future calls: 51

Originally I thought it was because i was updating more than 50 record. 
but I tried it again with 50 record and got the same message.

Plz guys help me out as soon as possible, i will be grateful.
If required to display my code then let me know.

Thanks in advance
Best Answer chosen by Dipen Ishani
BDatlaBDatla
Hi Dipen,

If possible please update your code to bulkify smiliar the way you did for triiger.new or else please use the getLimitFutureCalls() to limit 
the number of future calls as per gov limits.
Please find the below link to get more details on how to find the gov limits.
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm#apex_System_Limits_getLimitFutureCalls

  if(deleteflag){
        if(Trigger.isUpdate){
            for(Subscriber__c subs : Trigger.old) {                                                                   
                MDLiveIntegration.deleteSubs(subs.MDLIVE_ID__c,subs.id);             
            }

        }            
    }          

All Answers

NagaNaga (Salesforce Developers) 
Dear Dipen,

It would help if you can provide me with the code, but before that please check if you're calling the future method inside a loop, there might be multiple future calls because of that.

Best Regards
Naga Kiran
 
Dipen IshaniDipen Ishani
this is the code....
trigger SubscriberUpdateTrigger on Subscriber__c (after Insert, after Update, after delete) {
    
    List<ID> subRecords = new List<ID>();
    List<ID> subUpdateRecords = new List<ID>();
    Boolean deleteflag = false;
    if(!trigger.IsDelete) {
         
        for(Subscriber__c subs : Trigger.new){           

            if(subs.Active_Subscriber__c == true && subs.Auto_Telemedicine__c == true){
   
                Boolean needsUpdate = false ;        
                if(Trigger.isInsert){             
                    needsUpdate = true;
                } 
                else if (Trigger.isUpdate){                
                    needsUpdate = false;
                }                
                if(needsUpdate)
                    subRecords.add(subs.id);
                else
                    subUpdateRecords.add(subs.id);   
            }
            else
            {
                deleteflag = true;
            }
        }       
        if(subRecords.size() >0){             
           if(system.isFuture()) 
               return;  
           MDLiveIntegration.insertSubs(subRecords);     
       
        }       
        if(subUpdateRecords.size() >0){             
            if(system.isFuture()) 
                return;              
            MDLiveIntegration.updateSubs(subUpdateRecords);   
            MDLiveIntegration.reactiveSubs(subUpdateRecords);                              
        
        }       
    }
    else 
    {        
        for(Subscriber__c subs : Trigger.old) {                                                          
            if(subs.Active_Subscriber__c == true && subs.Auto_Telemedicine__c == true){    
                MDLiveIntegration.deleteSubs(subs.MDLIVE_ID__c,subs.id);    
            }       
        }
    }     
    
    if(deleteflag){
        if(Trigger.isUpdate){
            for(Subscriber__c subs : Trigger.old) {                                                                   
                MDLiveIntegration.deleteSubs(subs.MDLIVE_ID__c,subs.id);             
            }
        }            
    }          
}
BDatlaBDatla
Hi Dipen,

If possible please update your code to bulkify smiliar the way you did for triiger.new or else please use the getLimitFutureCalls() to limit 
the number of future calls as per gov limits.
Please find the below link to get more details on how to find the gov limits.
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm#apex_System_Limits_getLimitFutureCalls

  if(deleteflag){
        if(Trigger.isUpdate){
            for(Subscriber__c subs : Trigger.old) {                                                                   
                MDLiveIntegration.deleteSubs(subs.MDLIVE_ID__c,subs.id);             
            }

        }            
    }          
This was selected as the best answer
BDatlaBDatla
Hi Dipen,

Let me know if you need any more help.

Regards,
BDatla
Dipen IshaniDipen Ishani
Hi BDatla

I make the change in my code as said and i got the solution.
Thank you for your great help.