The new Duplicate Management brings in the new DMLOptions class DuplicateRuleHeader.

According to the Documentation, the property allowSave can be set to true, to force the database to ignore duplicate rules. In the example, 2 more properties are mentioned:

Database.DMLOptions dml = new Database.DMLOptions(); 
dml.DuplicateRuleHeader.allowSave = true;
dml.DuplicateRuleHeader.includeRecordDetails = true;
dml.DuplicateRuleHeader.runAsCurrentUser = true;
Account duplicateAccount = new Account(Name='dupe');
Database.SaveResult sr = Database.insert(duplicateAccount, dml);
if (sr.isSuccess()) {
    System.debug('Duplicate account has been inserted in Salesforce!');

No other explanation is given for

  • Database.DMLOptions.DuplicateRuleHeader.includeRecordDetails
  • Database.DMLOptions.DuplicateRuleHeader.runAsCurrentUser

and the only property with a reference is allowSave

What are the undocumented properties for?


I have run into this new property as well and it appears to be part of the new Summer 15 release. According to page 224 of the release notes:

New Properties

DMLOptions.DuplicateRuleHeader Class

   Set to true to get fields and values for records detected as duplicates. 
   Set to false to get only record IDs for records detected as duplicates.
   Set to true to make sure that sharing rules for the current user are
   enforced when duplicate rules run. Set to false to use the sharing rules
   specified in the class for the request. If no sharing rules are 
   specified, Apex code runs in system context and sharing rules for 
   the current user are not enforced.

Hope this information helps you decide how to use it.

  • I executed the Dominic posted code in Dev Console and I am getting the following error Variable includeRecordDetails not exist and same happened with the runAsCurrentUser, I commented out both lines then it went thru do I need to do any thing else to make it execute from Dev console – Suresh Jun 10 '15 at 14:49
  • Perhaps, your org has not been upgraded to Summer 15 yet? According to this post ledgeviewpartners.com/blog/… the remaining orgs will be updated on the 12th and 13th of June. – Sara Morgan Jun 11 '15 at 15:25
  • I executed this in office sandbox cs7.salesforce.com/home/home.jsp which is update to Summer 15. – Suresh Jun 11 '15 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.