Newer Version Available

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

DuplicateResult Class

Represents the details of a duplicate rule that detected duplicate records and information about those duplicate records.

Namespace

Datacloud

Usage

The DuplicateResult class and its methods are available to organizations that use duplicate rules.

DuplicateResult is contained within DuplicateError, which is part of SaveResult. SaveResult is generated when a user attempts to save a record in Salesforce.

Example

This example shows a custom application that lets users add a contact. When a contact is saved, an alert displays if there are duplicate records.

The sample application consists of a Visualforce page and an Apex controller. The Visualforce page is listed first so that you can see how the page makes use of the Apex controller. Save the Apex class first before saving the Visualforce page.

This sample is the Apex controller for the page. This controller contains the action method for the Save button. The save method inserts the new contact. If errors are returned, this method iterates through each error, checks if it’s a duplicate error, adds the error message to the page, and returns information about the duplicate records to be displayed on the page.

DuplicateResult Methods

The following are methods for DuplicateResult.

getDuplicateRule()

Returns the developer name of the executed duplicate rule that returned duplicate records.

Signature

public String getDuplicateRule()

Return Value

Type: String

getErrorMessage()

Returns the error message configured by the administrator to warn users they may be creating duplicate records. This message is associated with a duplicate rule.

Signature

public String getErrorMessage()

Return Value

Type: String

Example

This example shows the code used to display the error message when duplicates are found while saving a new contact. This code is part of a custom application that lets users add a contact. When a contact is saved, an alert displays if there are duplicate records. Review DuplicateResult Class to check out the entire sample applicaton.

getMatchResults()

Returns the duplicate records and match information.

Signature

public List<Datacloud.MatchResult> getMatchResults()

Return Value

Type: List<Datacloud.MatchResult>

Example

This example shows the code used to return duplicate record and match information and assign it to the matchResults variable. This code is part of a custom application that implements duplicate management when users add a contact. See DuplicateResult Class to check out the entire sample applicaton.

isAllowSave()

Indicates whether the duplicate rule will allow a record that’s identified as a duplicate to be saved. Set to true if duplicate rule should allow save; otherwise, false.

Signature

public Boolean isAllowSave()

Return Value

Type: Boolean