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.
- Navigate to the DC Setup
- Open the Object you want to work with in a Lightning Flow.
- 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.
- Open the Lightning Flow Builder.
- From the Elements section, drag a new Assignment to the screen from the toolbox on the left side.
An assigment is used to store the field values in a variable, so you can later use it to search with in the DC Flow action.
- 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.
- At "Set Variable Values", click in the "Search variables" field and choose "+ New Resource".
- At "Resource Type", choose "Variable".
- At "API Name", define an API name for the new variable.
- At "Data Type", choose "Record".
- At "Object", select the Object that you gather field values from.
For example, if you gathered field values from the Lead Object, select "Lead".
- Click Done.
- 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.
- Click Done.
Step 3 Use the "Find duplicates by field values" flow action
- From the Elements section, drag a new Action to the screen from the Toolbox on the left side.
- In the New Action dialog, search for Find Duplicate By Field Values.
- 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.
- 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.
- At "Set Input Values", select the Variable (containing the field values to search with) that you created at step 2.
- 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".
- 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).
||The record ID of the duplicate record with the highest matching score.
||The matching score of the highest scoring duplicate.
||The number of total duplicates found.
||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.