Salesforce DML Exception Cannot Have More Than 10 Chunks In A Single Operation

--

Exception:

System.TypeException: Cannot have more than 10 chunks in a single operation. Please rearrange the data to reduce chunking.

This exception is thrown when List < sObject > variable has more than 10 records of different types in a mixed fashion of multiple objects records.

Sample Code to reproduce the issue:

To fix the issue, sort the list so that the records are sorted by objects.

--

--

Alok Gupta

Tech enthusiastic, life explorer, single, motivator, blogger, writer, software engineer