1

We Duplicate rules enabled.

When converting a lead, a return page, with possible duplicates appear, with buttons: 'Convert to Selected' or 'Convert to New'

We have a custom page for the lead convert, but I would like to get this behavior on my page.

enter image description here

How is that possible? Which class/method do I need to call?

Database.LeadConvertResult - return the result set of duplicates.

I want that data will overwrite existing lead data.

I use this to display the list of available contacts, adding a radio button, how do I use it in the 'Save and ignore' dupcliate?

VF Page

<!-- added for duplicates -->
<apex:pageBlock title="Duplicate Records" rendered="{!hasDuplicateResult}">
    <apex:pageMessages />
    <apex:pageBlockTable value="{!duplicateRecords}" var="item">
        <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:outputLink value="/{!item['Id']}">{!item['Name']}</apex:outputLink>
        </apex:column>
        <apex:column >
            <apex:facet name="header">Owner</apex:facet>
            <apex:outputField value="{!item['OwnerId']}"/>
        </apex:column>                
        <apex:column >
            <apex:facet name="header">Account</apex:facet>
            <apex:outputField value="{!item['AccountId']}"/>
        </apex:column>
        <apex:column >
            <apex:facet name="header">Last Modified Date</apex:facet>
            <apex:outputField value="{!item['LastModifiedDate']}"/>
        </apex:column>
    </apex:pageBlockTable> 
    <apex:pageBlockButtons >
        <apex:commandButton value="Convert (Ignore Alert)" action="{!convertLeadIgnoreDuplicate}"/>
    </apex:pageBlockButtons>   
</apex:pageBlock> 
<!-- End code -->
3
  • 2
    Just curious, Database.LeadConvertResult doesn't return these details?
    – Ashwani
    Jul 2, 2018 at 12:29
  • It does, how to configure the buttons?
    – Saariko
    Jul 2, 2018 at 13:14
  • 1
    Are you asking specificlly how to add a Convert & Ignore button? Do you have the rest of the page working? Just that button can be done via the DMLOptions, specifically DMLOptions.DuplicateRuleHeader.allowSave = true. This should ignore any duplicate rules you have & just save the record. Jul 2, 2018 at 14:42

1 Answer 1

0

The end result was using the 'hadduplicaterecords' that is returning from the Database.leadConvert.

I have 2 buttons, that alternate accordingly.

        <div id="buttonBlock">
            <apex:commandButton value="Convert (Ignore Alert)" action="{!convertLeadIgnoreDuplicate}" rendered="{!hasDuplicateResult}"/>           
            <apex:commandButton value="Convert" id="convertButton"  action="{!convertLead}"  rendered="{!hasDuplicateResult == false}"/>
            <apex:commandButton value="Cancel" action="{!Cancel}" />
        </div>

The supporting method in the contorller is

public PageReference convertLeadIgnoreDuplicate() {
    PageReference pageRef = null;
    ignoreDuplicateAndConvert = true;

    pageRef = convertLead();
    return pageRef;
}

You must log in to answer this question.

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