FindDuplicates Class

Performs rule-based searches for duplicate records. The input is an array of sObjects. Each sObject represents a record you want to find duplicates of. The output identifies the detected duplicates for each input sObject based on active duplicate rules for the given object.

Namespace

Datacloud

FindDuplicates Methods

The following are methods for FindDuplicates.

findDuplicates(sObjects)

Identifies duplicates for sObjects provided and returns a list of FindDuplicatesResult objects.

Usage

Use FindDuplicates to apply active duplicate rules associated with an object to records represented by input sObjects.

FindDuplicates uses the duplicate rules for the object that has the same type as the input sObjects.

Input
  • All sObjects in the input array must be of the same object type, and that type must correspond to an object type that supports duplicate rules.
  • The input array is limited to 50 elements. If you exceed this limit, an exception is thrown with the following message: Configuration error: The number of records to check is greater than the permitted batch size.
Output
  • The output of FindDuplicates is an array of objects with the same number of elements as the input array, and in the same order. The output objects encapsulate record IDs for duplicate records. The output objects also contain values from the duplicate records.
  • Each element contains an array of DuplicateResult objects. If FindDuplicates doesn’t find any duplicates, the duplicateRule field in DuplicateResult contains the name of the duplicate rule that FindDuplicates applied, but the matchResults array is empty.

Example

Account acct = new Account();
acct.Name = 'Acme';
acct.BillingStreet = '123 Fake St';
acct.BillingCity = 'Springfield';
acct.BillingState = 'VT';
acct.BillingCountry = 'US';
        
List<Account> acctList = new List<Account>();
acctList.add(acct); 

if (Datacloud.FindDuplicates.findDuplicates(acctList).size()== 0) {
// If the new account doesn't have duplicates, insert it.
    insert(acct);
}

Signature

public static List<Datacloud.FindDuplicatesResult> findDuplicates(List<SObject> sObjects)

Parameters

sObjects
Type: List<SObject>
An array of sObjects for which you want to find duplicates.

Return Value

Type: List<FindDuplicatesResult>