How To

Flow Screen: This error occurred: MIXED_DML_OPERATION

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.”

Bummer.

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).

DeactivateaPortalUser-MixedDML-FINAL.gif

View image full screen

When you use the “Debug” feature in flow to unit test this, a flow fault has occurred due to a mixed DML operation:

FlowFault.GIF

Oopsie!

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.

ShoutOut.jpg

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!

DeactivateaPortalUser-FINAL.gif

View image full screen

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!

2 thoughts on “Flow Screen: This error occurred: MIXED_DML_OPERATION

  1. Nice piece of work, Jennifer. I didn’t even put together until you started investigating this that simple addition of a local action will commit the transaction. If I can find the time, I’ll publish a super simple local action called Commit Transaction, just to make it a little clearer.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s