Day 3 : Quickly fix mixed DML operations errors in Flows #TexeiAdventCalendar

By

2 minutes de lecture

Ho-ho-ho! Christmas is just around the corner and it is time for another little tip from our #TexeiAdventCalendar! Today we are going to speak about Mixed DML.

I hope you had a great time yesterday with Daniel Lopes’ article. Just in case you missed it, you can find it here learn what’s new for LWC in Winter 21.

Mixed DML

Debugging Flows and Process Builder can be tricky and painful. Even with the recent addition of the debugging mode in the Flow Builder. So today, I’ll give you a quick tip: how to avoid getting a “Mixed DML operation error” in your Flows and Processes.

A Mixed DML operation error occurs when you try to persist in the same transaction. Changes to a Setup Object and a non-Setup Object. For example, if you try to update an Opportunity record and a User record at the same time.

How to avoid this?

It’s pretty easy, you just need to make sure that these operations take place in different transactions. Which means adding an element or a process to close the first transaction.

  • In the Process Builder, the trick is: move your actions in scheduled actions that will be executed 0 hours from now. Basically the same as immediate actions.
  • In an Autolaunched Flow, you can just insert a Pause Element.
  • Finally, in a Screen Flow, organize your flow. So that your actions are either separated by a Screen Element or by a Local Action.

Hope you had a good read about Mixed DML! Come back tomorrow for a new article written by Fabien Taillon. And if you don’t want to wait, you can go to https://texei.com to see more content. Follow us on LinkedIn here and on Twitter here!

Read more posts

Enforce code standards with PMD

Developers working on a project usually set coding rules to have a standardized codebase. It is an important piece of the code maintainability, and it can be very easy …
March 2023
Advices
Scratch orgs

Uncovering Salesforce Settings: A Step-by-Step Guide for Scratch Orgs

Today, it’s pretty easy to build your Scratch Org definition file when you know what Settings you want to activate, as they are mapped with the same setting names …
February 2023
Advices
Business Analyst

Core qualities of a Business Analyst?

A common definition we are used to hear is that being a Business Analyst means to have a combination of both hard skills and soft skills. What does a …
June 2022
Advices
Image d'illustration d'une employée travaillant sur un ordinateur portable

Process builder and workflow make way to Flows (½)

Overview “If you can do it with a Workflow, then do it with a Process Builder, because everything a Workflow does, a Process Builder does it better”. If you …
March 2022
Advices

Day 22 : Salesforce new “Migrate To Flow tool” in Spring 22

As most of you already know, the workflow rules and process builders are planned to be retired in 2023 (no precise date defined so far). Today, I’m going to …
December 2021
Advices

Day 18 : Fake callout responses for test classes !

Hello everybody ! Today let’s talk about Apex tests classes in Salesforce. Everyone loves a good test class, and Salesforce makes it official by requiring to have a minimum …
December 2021
Advices