A Mixed DML Operation error occurs in Salesforce when a DML (Data Manipulation Language) operation on a setup object is mixed with a DML operation on a non-setup object in the same transaction. Setup objects are sObjects that control user access and permissions—such as User, UserRole, Group, and GroupMember. Non-setup objects include standard and custom records such as Account, Contact, Invoice, and custom objects.
Salesforce enforces this restriction to prevent data operations from executing with incorrect access-level permissions. For example, you cannot update an Account and a UserRole in a single transaction.
This error commonly appears in the following scenarios:
Example 1 — Process Builder Mixed DML:
A Process on the User object is configured with an Immediate Action to create a record on the Account object. When a new User is created and activated, the following error appears:
Error: An error occurred at element myRule_1_A1 (FlowRecordCreate). INSERT --- INSERT FAILED --- ERRORS : (MIXED_DML_OPERATION) DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Invoice_Statement__c, original object: User
Steps to reproduce:
Example 2 — Validation Rule Mixed DML:
When a custom Auth Provider RegistrationHandler calls updateUser() and the User object has a Validation Rule that references a Contact formula field (such as Contact.AccountId), the following error appears at login:
"We can't log you in because of the following error. ERROR_CREATING_USER: Validation Formula 'UserProfileSwitchRule' Invalid (java.lang.IllegalStateException: Programmer Error: you cannot mix EntityObjects with different UddInfos within one transaction: id = 003**********"
Steps to reproduce:
The following solutions address each scenario where a Mixed DML Operation error occurs.
Move the conflicting action from Immediate Actions to a Scheduled Action. Placing the action under Scheduled Actions separates the setup object operation from the non-setup object operation, running them in different transactions.
Scheduled Action is available when the Evaluation Criteria is set to one of the following:
Additionally, the option "Do you want to execute the actions only when specified changes are made to the record?" must be enabled under Advanced on the "Define Criteria for this Action Group" page.
The root cause is that the validation rule formula references Contact.Account, which loads a Contact entity into the same TransactionEntityObjectMap that contains the BlueID Auth Provider uddInfo. Salesforce does not allow mixing EntityObjects with different UddInfos in one transaction.
Note: Standard Auth providers such as Salesforce or Facebook are not affected by this limitation.
To resolve this issue, use one of the following approaches:
// update(u);
See more details about possible scenarios: sObjects That Cannot Be Used Together in DML Operations.
See information regarding APEX: Cannot Mix DML Operations.
Transactions and Scheduled Actions
000382600

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.