Flow Action - Find Duplicates By Field Values

Last published at: 2023-07-13 14:18:31 UTC

The Flow Action feature is available in the Premium Edition.


The "Find Duplicates by Field Values" flow action lets you search for duplicate records based on given field values. If duplicates are found, search results are returned that can be used in other DC flow actions. For example, use this flow action to check for duplicate records when inserting a new record via a Lightning screen flow.

Step 1 Apply a scenario to use in the Flow Action

Duplicate Check uses the applied scenario to decide how to compare records in a flow action. 

  1. Navigate to the DC Setup
  2. Open the Object you want to work with in a Lightning Flow. 
  3. At the scenario tab, decide which scenario you want to use and apply to scenario to "Flow" at "Apply To".
    By applying multiple scenarios to the same feature, Duplicate Check will return potential duplicates records via the OR method. Learn more about scenarios

Step 2 Store the field values to search with in a new variable

Field values gathered in a screen component, or in a non-UI flow, have to be stored in a variable to serve as input for the "Find Duplicates by Field Values" flow action. 

  1. Open the Lightning Flow Builder.
  2. From the Elements section, drag a new Assignment to the screen from the toolbox on the left side.

    An assignment is used to store field values in a variable, that you can later on use as input for the DC Flow action.
  3.  At "Label", define a name for the assignment. If the API name is not set automatically, make sure an API name is defined as well. 
  4. At "Set Variable Values", click in the "Search variables..." field and choose "+ New Resource". 
  5. At "Resource Type", choose "Variable". 
  6. At "API Name", define an API name for the new variable.  
  7. At "Data Type", choose "Record".
  8. At "Object", select the Object that you will gather field values from.
    For example, if you gather field values from the Lead Object, select "Lead"
  9. Click Done.
  10. At "Set Variable Values", make sure you store each of the field values that you gathered in the newly created variable.
    For example, map the "First Name" field value to the First Name field in the Lead Object variable. In the below example, we've stored First Name, Last Name, and Email in the variable.

    For searching in Person Account records, add a variable value 'Record type ID equals x', where x is the record type ID of the Person Account record type. If this variable is not used, the Account records are searched instead.

  11. Click Done.


You have now stored the field values you want to search with in a new variable that can serve as input for the "Find duplicates by field values" flow action.

Step 3 Use the "Find duplicates by field values" flow action

  1. From the Elements section, drag a new Action to the screen from the Toolbox on the left side.
  2. In the New Action dialog, search for Find Duplicate By Field Values. 
  3. At "Label", define a name for your action. If the API name is not set automatically, make sure an API name is defined as well. 
  4. At "Select Objects", in the "Search Objects" field, select the object related to the fields you want to search with.
    For example, if you gathered fields for a Lead, select the Lead Object. 
  5. At "Set Input Values", select the Variable (containing the field values to search with) that you created at step 2. 
  6. At "Search Cross Object", decide if you want to search for duplicates across multiple objects. If so, make sure to toggle the button to "Include" cross object. As a value, insert the Global Constant set to true.

    Please note that to search for duplicates across multiple objects, the "Cross Object" feature has to be enabled and configured. 
    If you want to search for duplicates in the same object only, make sure not to include "Cross Object". 
  7. Click Done. 

Step 4 Connect your actions to the start trigger

Make sure the Assignment and "Find Duplicates by Field Values" action are connected to the start trigger. 

In this example, we're first gathering the field values in a screen. Values are then stored in a variable (assignment) and then used as input for the "Find Duplicate by Field Value" action. 

Step 5 Run the flow

Run the flow by clicking "Run". 

Find Duplicate by Field Values action result 

After running the flow, this action returns different parameters that can be used further in the flow. For example, show a notification if a user is about to create a duplicate record. 

A boolean that returns "True" (duplicates are found) or "False" (no duplicates found).
Record ID
The record ID of the duplicate record with the highest matching score.
Matching Score
The matching score of the highest scoring duplicate.
Total Duplicates
The number of total duplicates found.
Duplicate Result
An Object containing all the Search Results of this action that you can use to return the duplicate results to a user in a flow.

Gather the duplicate IDs in a list

To collect the record IDs of the found duplicates in a list, add the 'DC - Get Duplicates IDs from Flow Output'‍ flow action after this flow action.