You need to sign in to do that
Don't have an account?
Getting Too Many DML Rows:10001 in trigger
trigger EstimateUpdateOnAccount1 on Estimates__c(after insert,after update)
{
List<Account> accsToUpdate = new List<Account>();
for(Estimates__c EST : trigger.new)
{
if( Trigger.isInsert)
{
if (est.year__c == '2012')
{
accsToUpdate.add(new Account(Id = EST.Account__c, Most_Recent_Estimate_Date__c =EST.Created_Date_Value__c, Estimate_Amount__c = EST.Estimate_Total_Fiscal__c ));
}
else
{accsToUpdate.add(new Account(Id = EST.Account__c, Most_Recent_Estimate_Date_2__c =EST.Created_Date_Value__c, Estimate_Amount_2__c = EST.Estimate_Total_Fiscal__c ));
}
if (accsToUpdate != null && !accsToUpdate.isEmpty())
Database.update(accsToUpdate);
}
if( Trigger.isUpdate)
{
if (est.year__c == '2012')
{
accsToUpdate.add(new Account(Id = EST.Account__c, Most_Recent_Estimate_Date__c =EST.Created_Date_Value__c, Estimate_Amount__c = EST.Estimate_Total_Fiscal__c ));
}
else
{accsToUpdate.add(new Account(Id = EST.Account__c, Most_Recent_Estimate_Date_2__c =EST.Created_Date_Value__c, Estimate_Amount_2__c = EST.Estimate_Total_Fiscal__c ));
}
if (accsToUpdate != null && !accsToUpdate.isEmpty())
Database.update(accsToUpdate);
}
}
}
When am doing upsert operation through data loader. Am getting the following error like "Too Many DML Rows:10001" can any one help me on this. why am getting this issue.wht mistake i done in trigger. Please give inputs on this ASAP. thanks in advance
try this.
You are using Database.update(accsToUpdate) in for loop. Its giving too many SOQL exception.
Try to take all items in list and then update outside for loop.
I just correct your code for showing DML out side for loop. Although Update and Insert coditions also can be merged if the logic in same for both.