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
liron169liron169 

System.TypeException: cannot have more than 10 chunks in a single operation

Hi,
I have this excpetion.
I already read other questions in this issue and understand what does it means.

However, in my code I'm adding only 2 type of sobjects + adding them per list. means:

list<object1> l_first;
list<object2> l_second;
list<sobject> lsobject;

lsobject.addAll(list<sobject> l_first);
lsobject.addAll(list<sobject> l_second);

database.insert (lsobject, false);


So according to what I read I don't supposed to have this exception.

It happen only lately for large volumes of data.
Is it possible that due to size of data in the final list (lsobject), SF split the list to chunks and then go back and forth from l_first object to l_second?
Otherwise, I cannot figure why I'm getting this error.

And if so, the only solution is to split it into 2 seperaed lists?

thanks.
bob_buzzardbob_buzzard
There's a discussion about this on the following blog post (not mine):

http://forcedotcode.com/system-typeexception-cannot-have-more-than-10-chunks-in-a-single-operation-2/
liron169liron169
Hi thanks but I already red this discussion.

I'm already doing as the propused solution there (the second option).


The solution is simple, make sure that your objects are grouped in the list either by adding your object this way or by keeping them in separate lists and adding those to the list of SObject at the end.
liron169liron169
Update.

Note that this is issue in SF (in my opinion it's bug).

If you will try to insert list of sObject with more then 1object type that contain more then 2000 records it will fail on this exception (probably due to the intenal chuncking of SF - 200 per DML.

I test it on list with 2000 records of customObj1,  + 1 record of customObj2, and got this execption.