Loading

Error 'Mixed DML Operation' when you create or update records through Process Builder or validation rule

Дата публикации: May 24, 2026
Описание

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:

  • A Process Builder or Flow that attempts to create or update a setup object and a non-setup object in the same transaction
  • A Validation Rule that references both setup and non-setup objects through formula fields
  • Custom Auth Provider implementations using a RegistrationHandler that updates the User object while the validation rule references a Contact field

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:

  1. Create a Process on the User Object
  2. Set the criteria as Active equals True
  3. Set the Immediate Action as Create Record on the Account object
  4. Activate the Process
  5. Create and Activate a New User

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:

  1. Login to Community URL
  2. Click Sign In
  3. Login using credentials for an authorized community user
  4. The error is generated
Решение

The following solutions address each scenario where a Mixed DML Operation error occurs.

Solution for Example 1 — Process Builder

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:

  • Created
  • When a record is created or edited

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.

Solution for Example 2 — Validation Rule with Custom Auth Provider

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:

  1. Comment out the update statement in the Auth registration handler — for example: // update(u);
  2. Modify the validation rule so it does not mix setup and non-setup entity objects
  3. Optional: Temporarily disable the validation rule to confirm it resolves the error
Дополнительные ресурсы


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

 
Загрузка
Salesforce Help | Article