Newer Version Available
DuplicateError
Fields
| Field | Details |
|---|---|
| duplicateResult |
|
| fields |
|
| message |
|
| statusCode |
|
Usage
DuplicateError and its constituent objects are available to organizations that use duplicate rules.
DuplicateError is a data type of Error.
To process duplicates, loop through all the Error objects in the errors field on SaveResult. An Error object with a data type of DuplicateError contains information about an error that occurred when an attempt was made to save a duplicate record. To access information about the duplicates, use the duplicateResult field.
Java Sample
Here’s a sample that shows how to see if there are any errors on the saveResult with a data type of DuplicateError. If so, duplicates were detected. See DuplicateResult for a full code sample that shows how to block users from entering duplicate leads and display an alert and a list of duplicates.
1if (!saveResult.isSuccess()) {
2 for (Error e : saveResult.getErrors()) {
3 if (e instanceof DuplicateError) {
4 System.out.println("Duplicate(s) Detected for lead with ID: " + leads[i].getId());
5 System.out.println("ERROR MESSAGE: " + e.getMessage());
6 System.out.println("STATUS CODE: " + e.getStatusCode());
7 DuplicateResult dupeResult = ((DuplicateError)e).getDuplicateResult();
8 System.out.println("Found the following duplicates...");
9 for (MatchResult m : dupeResult.getMatchResults()) {
10 if (m.isSuccess()) {
11 System.out.println("The match rule that was triggered was " + m.getRule());
12 for (MatchRecord mr : m.getMatchRecords()) {
13 System.out.println("Your record matched " + mr.getRecord().getId() + " of type "
14 + mr.getRecord().getType());
15 System.out.println("The match confidence is " + mr.getMatchConfidence());
16 }
17 }
18 }
19 }
20 }
21}