Mixed DML Operation in when creating or updating a record through Process Builder
|Knowledge Article Number||000240364|
|Description||DML operations on certain sObjects, sometimes referred to as setup objects, can’t be mixed with DML on other sObjects in the same transaction. This restriction exists because some sObjects affect the user’s access to records in the org. You must insert or update these types of sObjects in a different transaction to prevent operations from happening with incorrect access-level permissions.
For example, you can’t update an account and a user role in a single transaction.
If you use a Process to attempt to do both things in a single transaction an error will appear.
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
One example of 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.
When the action runs in the same transaction, instead of adding the Process Action to Immediate Action, add the Action under the Scheduled Action to make sure that the update or create action will run separately.