I have a custom matching rule set up for contact. I used that in my contact duplicate rule. When users fill contact data and try to save contact SFDC shows warning with duplicate result. but user can click on save button second time and it allows to save the record.

I know that we can bypass duplicate rules using apex. But I am trying to create a contact using apex. When I get duplicate match I am able to show the duplicate Result in UI as warning, but I want to save the contact when user click on "Save Contact" button second time just like in native lightning experience.

1 Answer 1


You would need to track if the duplicate warning has already been shown once, and if so, then use the normal method of bypassing duplicates in Apex. In Lightning, it would look like:

<aura:attribute name="duplicateConfirm" type="Boolean" default="false" />


saveRecord: function(component, event, helper) {
  var record = component.get("v.record"),
      dupConfirm = component.get("v.duplicateConfirm"),
      action = component.get("c.saveContactRecord");
  action.setParams( { dupConfirm: dupConfirm, record: record });
  action.setCallback(this, function(result) {
    // check if successful, else...
    component.set("v.duplicateConfirm", true);
    // ...
  • Thank for the reply. I got the idea, but I am not using lightning Component. I have a custom object called "Registration Form". I have written a trigger on "Registration Form " to get First Name, Last Name, Email, Phone, Address etc. and create a contact out of these info. What is the possible way to set a flag in trigger, so that I can use it in next transaction and bypass the duplicate rule?
    – Rajib
    Dec 1, 2018 at 10:41
  • @Rajib You probably should have included that in your original question. The answer is: you can't. Not in a trigger. You will need Visualforce/Lightning to keep track of the second attempt.
    – sfdcfox
    Dec 1, 2018 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .