You need to sign in to do that
Don't have an account?
System.LimitException: Too many DML statements: 151
I tried all the possible but couldnt find the right way..!!
I know the reason why I am getting "System.LimitException: Too many DML statements: 151". Its because Iam updating inside for Loop.
I I tried to remove from inside for loop But the updation is not happening.
"
public void saveme()
{
System.debug('In Save Me Method===');
try
{
Account updatedAcc;
String__c String;
List<Account> updatedAccList = new List<Account>();
List<String__c> updatedStringList = new List<String__c>();
System.debug('Records in Call plan === '+ListWrapper.size());
for(Wrapper wrapObj:ListWrapper)
{
updatedAcc = new Account();
updatedAcc = wrapObj.acc;
updatedStringList = wrapObj.acc.Strings__r;
System.debug('String === '+updatedStringList);
updatedAccList.add(updatedAcc);
update updatedStringList;
}
update updatedAccList;
}
catch(Exception e)
{
System.debug('Exception in Saving records == '+e.getMessage());
}
}
"
Please Help me in updating the record and Not to get governor limit error..
You can use the addAll method to build a full list of all the String__c objects to update rather then overriding the list of string objects per iteration. Something like this should do the trick:
All Answers
You can use the addAll method to build a full list of all the String__c objects to update rather then overriding the list of string objects per iteration. Something like this should do the trick:
Worked like Magic..
Thanks for the quick reply..