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 is 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.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17if (!saveResult.isSuccess()) {
18 for (Error e : saveResult.getErrors()) {
19 if (e instanceof DuplicateError) {
20 System.out.println("Duplicate(s) Detected for lead with ID: " + leads[i].getId());
21 System.out.println("ERROR MESSAGE: " + e.getMessage());
22 System.out.println("STATUS CODE: " + e.getStatusCode());
23 DuplicateResult dupeResult = ((DuplicateError)e).getDuplicateResult();
24 System.out.println("Found the following duplicates...");
25 for (MatchResult m : dupeResult.getMatchResults()) {
26 if (m.isSuccess()) {
27 System.out.println("The match rule that was triggered was " + m.getRule());
28 for (MatchRecord mr : m.getMatchRecords()) {
29 System.out.println("Your record matched " + mr.getRecord().getId() + " of type "
30 + mr.getRecord().getType());
31 System.out.println("The match confidence is " + mr.getMatchConfidence());
32 }
33 }
34 }
35 }
36 }
37}