DuplicateResult Class

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

Datacloud

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.

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.

See Also

The following are methods for DuplicateResult.

  • getDuplicateRule()

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

  • 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.

  • getMatchResults()

    Returns the duplicate records and match information.

  • 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.

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

public String getDuplicateRule()

Type: String

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.

public String getErrorMessage()

Type: String

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.

Returns the duplicate records and match information.

public List<Datacloud.MatchResult> getMatchResults()

Type: List<Datacloud.MatchResult>

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.

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.

public Boolean isAllowSave()

Type: Boolean