Solution for: System.TypeException: Cannot have more than 10 chunks in a single operation.

Hi All,

Assume that you have hybrid list of SObject.Which means many sobject records(Account,Contact,Lead etc) in single List.When you try to perform a DML operation on this list you will encounter the following error.

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

As all we know Salesforce platform runs everything(Soql,DML and CPU time etc) based on governor limit.The same is applying in this hybrid list.

Chunk processing for each call =10
       
Solution:
    Salesforce providing a default list method  called Sort() to solve this issue.
    
    Sort()- Using this method, you can sort primitive types, SelectOption elements,
            and sObjects (standard objects and custom objects).
    
    Code:    

updateList.Sort();

Update updateList;

Always keep in mind that hybrid list should be sorted before the DML operation.

Like if you like this article, Please comment if you have any suggestions.

Tags: 
Rating: 
Average: 4.8 (4 votes)