As we already have matching rules and duplicate rules in salesforce.I want to implement duplicate check as described below: I want to create a custome button that overrrides the salesforce standard button 'New'. When the custome button is clicked,it must first give a form that asks to enter basic info like First Name,Last Name,age etc.

After adding those basic things,there must be a button or anything that will first search the database for the similar records,notifies the user about the duplication if any,gives option to review those records and if it's a new record then,it asks the user whether to go to the detailed page of new client and add further info about the client to save the record to database.

How can i implement it on salesforce?


1 Answer 1


@Dipak Override New button by StandardController VF page, add two outputpanels one to enter data before checking duplicate and another to show detail page. Below is the sample code VF Page --> [apex:detail use] https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_detail.htm

<apex:page StandardController="Object" extension="Objectcontoller">
<apex:outputPanel rendered="{!IF(blnDetail==false)}">
    <apex:outputText name="fname"> 
    <apex:outputText name="lname"> 
    <apex:commandButton value="Validate" action="{!search}">
<apex:outputPanel rendered="{!blnDetail}"> 


public class Objectcontoller{
    public boolean blnDetail{get;set;}
    public string fname{get;set;}
    public string lname{get;set;}
    public Objectcontoller(){
         blnDetail= false;
    public void search(){
     //query to search duplicate and to other stuff

       blnDetail= true; // if you want to redirect to detail page
  • It will throw a Query timeout exception if there are lakhs of records and OP doesn't has appropriate filters in SOQL. Better to go with declarative way by using matching and duplicate rules which I highlighted in my comment. Jul 4, 2017 at 6:34

You must log in to answer this question.

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