I have 3 values in my picklist Account, Contact,Leads.

I need to display the duplicate records of selected objects, for example, I have selected Contact then it should display Contact duplicate records and so on.

How to achieve this?

Can someone help me out?

VF Page:

    <apex:pageBlock title="Duplicate Check" >

        <apex:pageBlockSection title="Select Object" columns="2" >
           <apex:selectList value="{!selectedvalue}" multiselect="false" size="1">
           <apex:selectOptions value="{!records}" />
           <apex:actionSupport event="onchange" action="{!updateData}" />


        <apex:outputText value="{!selectedvalue}" label="You have selected: "/>



public with sharing class Picklist {

    public List<Selectoption> Accounts {get; set;}
    public List<Selectoption> Contacts {get; set;}
    public List<Selectoption> Leads {get; set;} 
    public List<Contact> con{ get; set; }  
    public List<Account> acc{ get; set; }  
    public List<Lead> ld{ get; set; }   
    //public String search { get; set; } 
    public String selectedValue {get; set;}
    public list<selectOption> records{get;set;}

    public Picklist(){

     con=new List<Contact>();
      records = new List<selectOption>();
      records.add(new selectoption('Accounts','Accounts'));
      records.add(new selectoption('Contacts ','Contacts '));
      records.add(new selectoption('Lead','Lead '));      

   public void Picklist(){
   if(selectedvalue =='Contacts'){
     List<AggregateResult> con=[SELECT Email, COUNT(Id) FROM Contact GROUP BY Email HAVING COUNT(Id) > 1 ];
   else if(selectedvalue =='Accounts'){
     List<AggregateResult> acc=[SELECT Name, count(Id) FROM Account GROUP BY Name HAVING count(Id)>1];  

    public pageReference updateData(){

   return null;


Your Answer

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

Browse other questions tagged or ask your own question.