So, you built a flow that you think will work wonderfully just to get the following error when you run debug on your flow: “This error occurred: MIXED_DML_OPERATION: DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Account, original object: User.”
But you need this process to perform a DML action on both an non-setup object (standard or custom) and the user object.
So, what to do to fix this?!
This is a screen flow that updates an account and user record (see the blue box).
When you use the “Debug” feature in flow to unit test this, a flow fault has occurred due to a mixed DML operation:
If you run into this issue with a process, the resolution is to move these actions to a scheduled actions that execute 0 hours from now (essentially run as immediate actions).
If you run into this issue in an autolaunched flow, the resolution is to add a Pause flow element between the two DML actions. The Pause element will closed the DML action.
Shout out to Jason Teller, Salesforce Senior Director of Product Management of the Process Automation Team, for the assist.
To close the DML action, Jason told me that you needed to either add a Screen flow element or Local Action. This would need to be inserted in between the two DML actions.
I opted to add the Show Toast local action (refer to the below image that shows the Show Toast local action inserted between the two Update flow elements) so the user would not need to click the “Next” button on a screen flow to advance the flow progress. It shows a success message and the flow continues on. After I added it, my flow works like a charm. Thank you, Jason!
Note: Check out LightningFlow.net. This is the unofficial Web site managed by the Salesforce Process Automation Product Management team. There are lots of cool resources including installable local actions.
Best of luck to you!