Bypass Validation Rules in Salesforce Flow

newsletter Mar 30, 2024

Happy Saturday!

Have you ever wished you could bypass a validation rule in a Flow?

Just while the flow is running, skip that validation rule!

Here's a short walk through on how to do it using a custom permission and scheduled Flow paths.

Let's pretend you and I work at Universal Containers.

We have a Flow that creates new cases when an Opportunity is Closed Won.

And we want to make sure Case Validation rules never block the Flow from running.

Further, in our pretend jobs at Universal Containers, there is currently a validation rule which says the Contact field on a Case can't be empty.

Triggering our Flow by putting an Opportunity into Closed Won throws a big red error message (because we didn't map the Contact field in the create Case element).

We could absolutely map the Contact field in our Flow and solve this error that way.

But this method is for when you need to skip the rule entirely.

To make our Flow immune to this rule we'll take the following steps.

Step 1: Create a Custom Permission

Name it: Bypass Validation Rules

Step 2: Create a Permission Set

Name it the same as our Custom Permission: Bypass Validation Rules

Step 3: Add the Custom Permission to the Permission Set

  • Go to the Permission Set from the Setup menu
  • Click Custom Permissions
  • Move the Custom Permissions to the Enabled Column
  • And then press Save

Step 4: Exempt Users with this Permission Set from the Validation Rule

Use the Insert Field functionality and the NOT() formula to add the exemption to the rule.

Step 5: Update our Flow

With our Permission Set created, and our Validation Rule updated, we can use the Flow to assign our Bypass Validation Rule permission set to the current running user.

By assigning the permission set before the Flow creates the Case, the Flow doesn't trigger the Case validation rule!

After the Case is created, we'll want to unassign the Bypass Validation Rule from the running user so they have to follow the rule again.

To make all this work, we use three scheduled Flow paths.

  • The first path runs right away and Assigns the Permission
  • The second path runs 1 minute later and creates the Case
  • The third path runs 2 minutes later and Unassigns the Permission

The reason we need three scheduled Flow paths is to avoid a MIXED_DML_OPERATION error (otherwise it would be much easier to put all these operations in a single path).

Each scheduled path gets its own transaction, meaning it doesn't trigger the MIXED DML error.

And there you have it, five steps to Bypass Validation Rule in your Flows :)

 

Have a great weekend!

 

Best,

Nick

P.S. If you're interested in the nitty gritty, I've posted screenshots of the Flow scheduled path and element configuration down below.

1. Assign Permission Set Path Configuration

a. Path Configuration

 

b. Path Order on Canvas

 

c. Get Bypass Validation Rule Permission Element

d. Assign Permission Set Element

 

 

2. Create Path Configuration

a. Path Configuration

 

b. Path Order on Canvas

c. Create Case Element

 

3. Delete Permission Set Path Configuration

a. Path Configuration

 

b. Path Order on Canvas

 

c. Get Bypass Validation Rule Permission Element

 

d. Get Permission Set Assignment Element

 

e. Delete Permission Set Assignment Element

 

3. When Triggered All Paths Appear in Time-Based Workflows 

 

Salesforce Made Simple

Join the Salesforce Saturday newsletter. Every Saturday, you'll get 1 actionable tip on Salesforce technology or career growth related to the Salesforce Industry.

We hate SPAM. We will never sell your information, for any reason.