You need to sign in to do that
Don't have an account?
Too many future calls: 51 Error - Please Help
Hello Devs, I have the following Trigger and Class that was working fine until this morning when I received the following error of Too Many future calls: 51.
Any idea how to alleviate gettign this error? Here is my trigger and class code....thank you all for any help you can provide....
Trigger:
Class code:
Any idea how to alleviate gettign this error? Here is my trigger and class code....thank you all for any help you can provide....
Trigger:
trigger DeleteExtraBookingsTrigger on Opportunity (after insert) { For(Opportunity opps : Trigger.new){ If(opps.Auto_Bookings__c == True){ DeleteExtraBookingsClass.deleteRecords(Trigger.newMap.keySet()); } } }
Class code:
public class DeleteExtraBookingsClass { @future public static void deleteRecords(Set<ID> oppIdsToDelete){ List<Opportunity> opp = [SELECT ID, Armor_Product_Category__c From Opportunity WHERE ID IN : oppIdsToDelete AND Auto_Bookings__c = True AND (Armor_Product_Category__c = null or Armor_Product_Category__c = 'Armor | null')]; If(opp.size()>0){ delete opp; database.emptyRecycleBin(opp); } } }
Please do not call another class within loop. Try to extract data into one List and send list to process. Please find the updated code below:
Thanks,
Gaurav
Skype: gaurav62990