Newer Version Available
findDuplicatesByIds()
Performs rule-based searches for duplicate records. The input is an array of IDs, each of which specifies the records for which to search for duplicates. The output identifies the detected duplicates for each object that supplies the duplicate rules. findDuplicatesByIds() applies the rules to the record IDs to do the search. The output identifies the detected duplicates for each ID.
Syntax
Usage
Use findDuplicatesByIds() to apply 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.
Matching is controlled by the values specified by the input record ID. The values can include a record ID only.
findDuplicatesByIds() 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.
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. Optionally, the output objects also contain values from the duplicate records.
Each element contains a DuplicateResult object. If findDuplicatesByIds() doesn’t find any duplicates for an sObject, the duplicateRule field in DuplicateResult contains the name of the duplicate rule that findDuplicatesByIds() applied, but the matchResults array is empty.
If the includeRecordDetails flag in DuplicateRuleHeader is set to false, findDuplicatesByIds() returns only the record IDs of the matching records. Otherwise, findDuplicatesByIds() returns all the fields specified in the primary CompactLayout associated with the target object.
Basic Steps for Using
- Create one or more ID objects that correspond to the object that has the duplicate rules you want to use.
- Specify record IDs to compare to records in the object.
- 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 |
|---|---|---|
| IDs | Array of ID | Required. A list of IDs 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 ID 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 findDuplicatesByIds() to a single sObject. |
| errors | Array of Error objects | Contains an array of errors encountered by findDuplicatesByIds(). |
| success | boolean | This field is set to true if findDuplicatesByIds() doesn’t encounter any errors. |