You need to sign in to do that
Don't have an account?
Michael Minnekeer
Too many DML rows 10001
Hi everyone
I am having an issue with my code that I should not get. I definitely have more than 10,000 opportunities/accounts in production but my code should only be updating the opportunities related to the account of the event I am inserting. I am getting this error when trying to insert the event on an account with less than 20 related opportunities. Any help is appreciated thanks.
Apex Trigger:
Apex Class:
I am having an issue with my code that I should not get. I definitely have more than 10,000 opportunities/accounts in production but my code should only be updating the opportunities related to the account of the event I am inserting. I am getting this error when trying to insert the event on an account with less than 20 related opportunities. Any help is appreciated thanks.
Apex Trigger:
trigger EventTrigger on Event (before insert, before update) { if(Trigger.isInsert){ list<Event> CSTIMPList = new list<Event>(); for(Event evnt : trigger.new){ if(evnt.Implementation_App_Type__c != null && evnt.System_Admin_Over_Ride__c != 'Mark Complete App Date'){ if(evnt.Implementation_App_Type__c == 'CST'){ CSTIMPList.add(evnt); } } } if(CSTIMPList.size() > 0 && CSTIMPList != null){ Event_HDL.updateimpdateCST(CSTIMPList); } } }
Apex Class:
public class Event_HDL { public static void updateimpdateCST(Event[] evnts){ List<Opportunity> OppList = new list<Opportunity>(); List<Account> relatedacclist = new list<Account>(); //map the Opportunity record Map<Id, List<Event>> oppIds = new Map<Id, List<Event>>{}; for(Event evnt : evnts){ oppIds.put(evnt.WhatId, new list<Event>()); oppIds.get(evnt.WhatId).add(evnt); } //map the account Map<Id, List<Opportunity>> soaIds= new Map<Id, List<Opportunity>>{}; Map<Id, List<Opportunity>> accIds= new Map<Id, List<Opportunity>>{}; for(Opportunity opp : [Select Id, AccountId, Implementation_Appointment_Date__c, Account.Regarding_Review_FP__c, Account.Regarding_Review_Super__c, Account.Regarding_Review_ROA__c from Opportunity where Id in: oppIds.keySet()]){ soaIds.put(opp.Account.Regarding_Review_FP__c, new list<Opportunity>()); soaIds.put(opp.Account.Regarding_Review_Super__c, new list<Opportunity>()); soaIds.put(opp.Account.Regarding_Review_ROA__c, new list<Opportunity>()); soaIds.get(opp.Account.Regarding_Review_FP__c).add(opp); soaIds.get(opp.Account.Regarding_Review_Super__c).add(opp); soaIds.get(opp.Account.Regarding_Review_ROA__c).add(opp); accIds.put(opp.AccountId, new list<Opportunity>()); accIds.get(opp.AccountId).add(opp); } //update the related account with the new imp app date for(Account acc : [Select Id from Account where Id in: accIds.keySet()]){ for(Event evnt : evnts){ acc.CST_Implementation_Appointment_Date__c = evnt.StartDateTime; } relatedacclist.add(acc); } if(relatedacclist.size() > 0 && relatedacclist != null ){ update relatedacclist; } //update all cst soas and recommendations(only from the latest review) off the back of them with the new imp app date for(Opportunity opp : [Select Id from Opportunity where Related_SOA__c in: soaIds.keySet() OR Id in: soaIds.keySet()]){ for(Event evnt : evnts){ opp.Implementation_Appointment_Date__c = evnt.StartDateTime; opp.Trust_Deed_Date__c = evnt.StartDateTime; opp.Trust_Deed_Appointment_Date__c = evnt.StartDateTime; } OppList.add(opp); } //update the opportunities if(OppList.size() > 0 && OppList != null){ update OppList; } } }
Ruthvik K 5
Looks like row 33 is causing the recurssive in trigger. To identify the root cause, add few debug statements