+ Start a Discussion
Sameer PrasonnSameer Prasonn 

MIXED_DML_OPERATION

Hi All,

What is "MIXED_DML_OPERATION"? and when it encountered? how to resolve this error? 

Thank you in advance.
Best Answer chosen by Sameer Prasonn
umesh atryumesh atry
sObjects That Cannot Be Used Together in DML Operations

Some sObjects require that you perform DML operations on only one type per transaction. For example, you cannot insert an account, then insert a user or a group member in a single transaction. The following sObjects cannot be used together in a transaction:

* Group1 * GroupMember * QueueSObject * User2 * UserRole * UserTerritory * Territory

Important The primary exception to this is when you are using the runAs method in a test.

In addition, the Summer 08 Release notes (that link is a PDF) say:

In previous releases, in a single transaction that involved triggers, you could perform DML operations on more than one type of sObject, for example, you could insert an account, then insert a user. As of Summer '08, you can only perform DML operations on a single type of sObject from the following list of sObjects.

For example, you cannot insert an account, then insert a user, or update a group, then insert a group member.

Group
GroupMember
QueueSObject
User
UserRole
UserTerritory
Territory

In addition, User and Territory now support the insert and update DML operations, and UserRole now supports the insert, update delete and upsert DML operations.

Apex DML operations are not supported on the following sObjects:

AccountTerritoryAssignmentRule
AccountTerritoryAssignmentRuleItem
UserAccountTeamMember