How to Bypass Duplicate Rules in Flow

How to Bypass Duplicate Rules in Flow

Duplicate rules in Salesforce help maintain clean and consistent data. They identify and block or alert users about potential duplicate records, such as leads, contacts, or accounts. These rules work based on matching criteria defined through matching rules. They can either allow or prevent the creation or update of duplicate records. While they are useful for keeping data clean, in some cases like automation through Flow, you may need to bypass them to avoid interruptions. Here is a workaround to bypass duplicate rules in Flow.

How to Temporarily Bypass Duplicate Rules

You can add conditions to duplicate rules to target records that meet certain criteria. This means you can also add a condition to bypass duplicate rules in Flow. To do this, you need to update a field on the record that helps skip the rule. However, you don’t want the record to be exempt from duplicate rules permanently, only during the Flow.

Unlike validation rule criteria, you cannot use the ISCHANGED() function in duplicate rule conditions. Therefore, you cannot simply bypass duplicate rules when a field is changed, as you can do to bypass validation rules. If you use an editable field like a checkbox, you’ll need to reset it later. That can re-trigger the duplicate rule and cause your Flow to fail. A better solution is to use a field that stops meeting the condition automatically after the Flow finishes. What kind of field can do that? A formula field!

Let’s assume you have a duplicate rule on the Lead object, and you want to allow creating or updating duplicate Lead records in a Flow. You can achieve this using two custom fields:

The first field can be a date/time field and you should populate it in your Flow with the current date/time.

Bypass Duplicate Rules in Flow

This field will not be used directly in the duplicate rule. As mentioned before, you need a checkbox formula field that returns "true" for a very short time (so that it stops meeting the criteria shortly after). Here is the formula for the checkbox field:

Bypass_Duplicate_Rules_Date_Time__c + (2/86400) >= NOW()

2/86400 means 2 seconds.

Conditions to Bypass Duplicate Rules

When you create or update the Lead record using Flow, it will populate the field and therefore bypass the duplicate rule. However, if you manually create or update the record, the duplicate rule will fire and block you.

Flow Bypasses the Duplicate Rules

As you can see, the Flow has successfully created a duplicate Lead. However, if you try to create the same record manually, the duplicate rule will block you.

Duplicate Rule Error

2 Comments

  1. Thanks for sharing, this is very helpful. Does it matter if the Flow is "Before record is saved" (Fast Field Update) or "After record is saved"?

Leave a Reply

Your email address will not be published.


*