Newer Version Available
DuplicateResult Class
Namespace
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.
getErrorMessage()
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()
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()
Signature
public Boolean isAllowSave()
Return Value
Type: Boolean