No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
DMLOptions.DuplicateRuleHeader Class
Determines whether a record that’s identified as a duplicate can be
saved. Duplicate rules are part of the Duplicate Management feature.
Namespace
Example
The following example shows how to save an account record that’s been identified as a
duplicate. To learn how to iterate through duplicate errors, see DuplicateError Class
1Database.DMLOptions dml = new Database.DMLOptions();
2dml.DuplicateRuleHeader.AllowSave = true;
3Account duplicateAccount = new Account(Name='dupe');
4Database.SaveResult sr = Database.insert(duplicateAccount, dml);
5if (sr.isSuccess()) {
6 System.debug('Duplicate account has been inserted in Salesforce!');
7}DMLOptions.DuplicateRuleHeader Properties
The following are properties for DMLOptions.DuplicateRuleHeader.
allowSave
Set to true to save the
duplicate record. Set to false to prevent the
duplicate record from being saved.
Signature
public Boolean AllowSave {get; set;}
Property Value
Type: Boolean
Example
This example shows how to save an account record that’s been identified as a duplicate.
dml.DuplicateRuleHeader.allowSave = true means the
user should be allowed to save the duplicate. To learn how to iterate through duplicate
errors, see DuplicateError Class.
1Database.DMLOptions dml = new Database.DMLOptions();
2dml.DuplicateRuleHeader.allowSave = true;
3dml.DuplicateRuleHeader.includeRecordDetails = true;
4dml.DuplicateRuleHeader.runAsCurrentUser = true;
5Account duplicateAccount = new Account(Name='dupe');
6Database.SaveResult sr = Database.insert(duplicateAccount, dml);
7if (sr.isSuccess()) {
8 System.debug('Duplicate account has been inserted in Salesforce!');
9}