4

I had to create a vfp for the "Lead new"-page, because I had to add a few lines of jscript into it. Now Duplicate Rules won't work properly. When I try to save a dupe I get the Error properly but there is no save(ignore) button.

How it Should Look How it should look: How it looks:

How it looks:

4

You can provide the same functionality in apex using DuplicateRuleHeader class

Below is the sample code to get you started

Database.DMLOptions dml = new Database.DMLOptions(); 
dml.DuplicateRuleHeader.allowSave = 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!');
}

Depending on allowSave boolean you can either force save or stop the save action .

  • Thank you. That is pretty much what I looked for, sadly I cant use Apex (Working in a Professional Edition). Is there maybe a way to include 2 custom buttons, one to ignore the rule and anotherone to redirect the user to a duplication check? – Tim Werner Mar 3 '16 at 7:54
1

Please use below syntax to include any custom button into your VF page:

<apex:commandButton action="{!URLFOR($Action.Your_Object_c.Your_Custom_Button_Name_c)}" value="My custom button"/>

Hope it helps.

  • I'm not sure he's actually looking for a custom button. I think he wants the standard save button. – Chris Fellows Mar 2 '16 at 18:38

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.