Newer Version Available

This content describes an older version of this product. View Latest

findDuplicates()

Performs rule-based searches for duplicate records.

The input is an array of sObject, each of which specifies the values to search for and the type of object that supplies the duplicate rules. The output identifies the detected duplicates for each object that supplies the duplicate rules. findDuplicates() applies the rules to the values to do the search. The output identifies the detected duplicates for each sObject.

Syntax

Usage

Use findDuplicates() to apply duplicate rules associated with an object to values specified by each sObject. Each sObject also has a type that corresponds to an object.

findDuplicates() uses the duplicate rules for the object that has the same type as the sObject. For example, if the sObject type is Account, findDuplicates() uses the duplicate rules associated with the Account object.

For each input sObject, findDuplicates() adds a FindDuplicatesResult object to the output array.

  • All the sObject elements in the input array must have the same 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, the SOAP call returns an API Fault Element containing these fields.
  • ExceptionCode: LIMIT_EXCEEDED
  • exceptionMessage: Configuration error: The number of records to check is greater than the permitted batch size.

Note

The values specified in the sObject control matching. The values can include a record ID, a field map, or both. The specified values determine the behavior of findDuplicates():

Record ID only
findDuplicates() searches the object defined by the duplicate rule for an existing record that has the same ID. Then it loads the values from that record, and searches for duplicates based on those values.
Field Map only
findDuplicates() loads the values from the map and searches for duplicates based on those values.
Record ID and Field Map
findDuplicates() searches the object defined by the duplicate rule for an existing record that has the same ID. It loads any values from that record that aren’t specified in the map, and then loads values from the map. Based on the resulting union of values, findDuplicates() searches for duplicates.

The output of findDuplicates() is an array of FindDuplicatesResult 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, if any. Optionally, the output objects also contain values from the duplicate records.

Each FindDuplicatesResult element contains a DuplicateResult object. If findDuplicates() doesn't find any duplicates for an sObject, the duplicateRule field in DuplicateResult contains the name of the duplicate rule that findDuplicates() applied, but the matchResults array is empty.

If the includeRecordDetails flag in DuplicateRuleHeader is set to false, findDuplicates() only returns the record IDs of the matching records. Otherwise, findDuplicates() returns all the fields specified in the primary CompactLayout associated with the target object.

Basic Steps for Use

  1. Create one or more sObject objects with a type that corresponds to the object that has the duplicate rules you want to use.
  2. In each sObject, specify record IDs or field maps (or both) to compare to records in the object.
  3. Set DuplicateRuleHeader to control the output you want.

Sample

The following Java sample demonstrates how to search for duplicates of a Lead, using the standard Leads duplicate rule.

Arguments

Name Type Description
sObjects Array of sObject Required. A list of sObject objects that contain values you want to search for.

Response

An array of FindDuplicatesResult objects.

FindDuplicatesResult

Represents the result of a duplicate search for a single sObject in the input array. Because the object associated with the sObject can have more than one duplicate rule, FindDuplicatesResult contains an array of DuplicateResult objects.

Fields

Field Name Field Type Description
duplicateResults Array of DuplicateResult objects The result of each duplicate rule applied by findDuplicates() to a single sObject.
errors Array of Error objects Contains an array of errors encountered by findDuplicates().
success boolean This field is set to true if the findDuplicates() doesn't encounter any errors.