この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

DuplicateResult

重複レコードを検出した重複ルールの詳細と、それらの重複レコードに関する情報を表します。

項目

項目 詳細
allowSave
boolean
説明
重複を保存できる場合は true。重複を保存できない場合は false
duplicateRule
string
説明
重複レコードを検出した重複ルールの名前。
duplicateRuleEntityType
string
説明
重複レコードを検出した重複ルールの名前。
errorMessage
string
説明
重複レコードを作成している可能性があることをユーザに警告するために、システム管理者が設定したエラーメッセージ。このメッセージは重複ルールに関連付けられています。
matchResults
MatchResult
説明
重複レコードおよび関連する一致情報。

使用方法

重複ルールを使用する組織は、DuplicateResult とその構成要素オブジェクトを使用できます。

Java のサンプル

重複するリードのユーザによる入力をブロックし、アラートと重複のリストを表示する方法の例を次に示します。

1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17package com.doc.example;
18
19import java.io.FileNotFoundException;
20
21import com.sforce.soap.partner.*;
22import com.sforce.soap.partner.Error;
23import com.sforce.soap.partner.sobject.SObject;
24import com.sforce.ws.ConnectionException;
25import com.sforce.ws.ConnectorConfig;
26
27public class SaveResultsWithDupeHeader {
28
29    private PartnerConnection partnerConnection = null;
30    static SaveResultsWithDupeHeader tester;
31
32    public static void main(String[] args) {
33        tester = new SaveResultsWithDupeHeader();
34        try {
35            tester.demoDuplicateRuleHeader();
36        } catch (Exception e) {
37            e.printStackTrace();
38        }
39    }
40
41    /*
42     * Make sure that you have an active lead duplicate rule linked to an active matching rule. This method tries to save
43     * an array of leads and inspects whether any duplicates were detected
44     */
45    public void demoDuplicateRuleHeader() throws FileNotFoundException, ConnectionException {
46        // Create the configuration for the partner connection
47        ConnectorConfig config = new ConnectorConfig();
48        config.setUsername("user@domain.com");
49        config.setPassword("secret");
50        config.setAuthEndpoint("authEndPoint");
51        config.setTraceFile("traceLogs.txt");
52        config.setTraceMessage(true);
53        config.setPrettyPrintXml(true);
54
55        // Initialize the connection
56        partnerConnection = new PartnerConnection(config);
57
58        // Get the leads that have to be saved
59        SObject[] leads = getLeadsForInsertOrUpdate();
60
61        /* Set a duplicate rule header to return a result if duplicates are detected
62         * This sets the allowSave, includeRecordDetails, and runAsCurrentUser flags to true
63         */
64        partnerConnection.setDuplicateRuleHeader(true, true, true);
65
66        // Save the leads
67        SaveResult[] saveResults = partnerConnection.create(leads);
68
69        // Check the results to see if duplicates were detected
70        for (int i = 0; i < leads.length; i++) {
71            SaveResult saveResult = saveResults[i];
72            if (!saveResult.isSuccess()) {
73                for (Error e : saveResult.getErrors()) {
74                // See if there are any errors on the saveResult with a data type of DuplicateError
75                    if (e instanceof DuplicateError) {
76                        System.out.println("Duplicate(s) Detected for lead with ID: " + leads[i].getId());
77                        System.out.println("ERROR MESSAGE: " + e.getMessage());
78                        System.out.println("STATUS CODE: " + e.getStatusCode());
79                        DuplicateResult dupeResult = ((DuplicateError)e).getDuplicateResult();
80                        System.out.println("Found the following duplicates...");
81                        for (MatchResult m : dupeResult.getMatchResults()) {
82                            if (m.isSuccess()) {
83                                System.out.println("The match rule that was triggered was " + m.getRule());
84                                for (MatchRecord mr : m.getMatchRecords()) {
85                                    System.out.println("Your record matched " + mr.getRecord().getId() + " of type "
86                                            + mr.getRecord().getType());
87                                    System.out.println("The match confidence is " + mr.getMatchConfidence());
88                                    for (FieldDiff f : mr.getFieldDiffs()) {
89                                        System.out.println("For field " + f.getName() + " field difference is "
90                                                + f.getDifference().name());
91                                    }
92                                }
93                            }
94                        }
95                    }
96                }
97            }
98        }
99
100        // Clear the duplicate rule header
101        partnerConnection.clearDuplicateRuleHeader();
102    }
103
104    /**
105     * The assumption here is that this method is retrieving leads from either UI, a data source, etc
106     */
107    private SObject[] getLeadsForInsertOrUpdate() {
108        return new SObject[0];
109    }
110
111}