[SalesForce] I cannot get the workaround for the Process Builder – Duplicate Management bug working

There is this incredibly frustrating bug concerning a conflict between the Process Builder and Duplicate Management.

Some people have suggested a workaround for it, but I can't get it to work, the conflict is still happening for me.

This is the workaround, thanks goes to Yi-Hs Tsai and Manu Devaraju:

For those looking for a work around to this very annoying problem, here's a solution that I've found works:

Create a checkbox field on the object called "Allow duplicates?" with default set to false.
In your Duplicate rule definition, include this new field under the "Conditions" section.
In your flow or process builder, BEFORE you update the record, first do an update where you set the "Allow duplicates?" field to true.  Then perform the update you want.
Since "Allow duplicates?" is checked and the update no longer meets the rule conditions, so shouldn't trigger the duplicate rule.
If you want the duplicate rule to run in the future for this record, you can do another record update to uncheck the "Allow duplicates?" field.

For instance, I have a duplicate rule on Contacts that has a whole bunch of matching criteria.  Following the steps I:

Create a field on the Contact object called "Allow Duplicates?" with default unchecked.
In my duplicate rule (Setup -> quickfind -> Duplicate Rules), I set a condition: "Contact: Allow Duplicates? EQUALS False"
In my flow, I have a step where I set Allow Duplicates? = true and update my record.
In my flow, then I perform the update on the email, phone, etc., that ordinarily would trigger the rule because of the my matching criteria.
In my flow, when I'm all done, I set the Allow Duplicates? back to false.

Someone else (Daniel DeAguilar) had some more on this:

So what i did was created the allow duplicates checkbox Yi-Hs mentions on my Account object (default unchecked), and in process builder did the following steps:

Under 'Choose Object and Specify When to Start the Process' i had recursion enabled (this was key)
1st node in process was looking for whenever my parent account field was changed
Immediate action in 1st node was changing duplicate checkbox to 'checked/true'
instead of stop i had 'evaluate next criteria' and go to 2nd node'
2nd node looked for when duplicate checkbox = true/checked
immediate action #1 to set parent account lookup to parent account id field (enabling lookup related lists)
immediate action #2 to set duplicate checkbox = false/unchecked

In the debug log I can see that the process is being run and after that the duplicate detection runs and everything is OK, the new custom field has the proper value and detection is prevented.

But after that more processing goes on and duplicate detection runs once more and this time the new custom field has its default value, so it doesn't prevent detection and you get the DUPLICATES_DETECTED error that the process cannot handle.

Most mystifying for me is where/how exactly the 'Allow duplicates' field must be updated. The process builder does not have an explicit Update command/option.

Here's a screenshot of my process builder configuration:

enter image description here

Best Answer

Looking further down in the comments on that idea to see the original comment/workaround by Manu Devaraju explains this much better. Below is the steps copied/pasted.

  1. Create a New picklist field 'Override Duplicate' (Yes/No) on the Contact object

  2. Create a Matching rule for the combination of First Name, Last Name and Phone number

  3. Create a Duplicate rule with a Matching rule created in the above step a. In the duplicate rule, look for the below section and the in the criteria add the field 'Override Duplicate' and the value as 'No' b. The above condition means that you want to run the duplicate rule only if 'Override Duplicate' field value is 'No' Conditions Optionally, specify the conditions a record must meet for the rule to run.

  4. In the process builder/flow, when you are trying to create a new record or updating an exist record set this addtional field 'Override Duplicate' as 'Yes' - that means you are trying to by pass the duplicate rules explicity in the flows so that flows will NOT throw any error message

  5. Use the workflow rules and field updates to Unset the 'Override Flag' to 'No' immediately after process builder updates it to 'Yes' Workflow Rule name : WF Unset Override duplicate Flag conditions : Override Duplicate = Yes Action : Call Workflow Field Update Workflow Field Update Name : WFU Unset Override duplicate Flag Field to Update : Override Duplicate Flag Value : No

The key seems to be having WF do the final update to set the flag back to False. This does not run into the bug (which is specific to PB).

Related Topic