FindDuplicatesByIds Class

Performs rule-based searches for duplicate records. The input is an array of IDs. Each ID specifies records to search for duplicates among. The duplicates are detected based on the active duplicate rules applicable to the object type corresponding to the input IDs.

Namespace

Datacloud

FindDuplicatesByIds Methods

The following are methods for FindDuplicatesByIds.

findDuplicatesByIds(ids)

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

Usage

Use FindDuplicatesByIds to apply active duplicate rules associated with an object to records represented by the record IDs.

FindDuplicatesByIds uses the duplicate rules for the object that has the same type as the input record IDs. For example, if the record ID represents an Account, FindDuplicatesByIds uses the duplicate rules associated with the Account object.

Input
  • All record IDs 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 FindDuplicatesByIds 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 FindDuplicatesByIds doesn’t find any duplicates, the duplicateRule field in DuplicateResult contains the name of the duplicate rule that FindDuplicatesByIds applied, but the matchResults array is empty.

Example

Account acct = new Account(name='Salesforce');
insert acct;

List<Id< idList = new List<Id<();
idList.add(acct.id);

if (Datacloud.FindDuplicatesByIds.​findDuplicatesByIds(idList).size() ​> 0) {
System.debug('Found duplicates');
}

Signature

public static List<Datacloud.FindDuplicatesResult> findDuplicatesByIds(List<Id> ids)

Parameters

ids
Type: List<ID>
A list of IDs for which you want to find duplicates.

Return Value

Type: List<FindDuplicatesResult>