function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gaganSFDCgaganSFDC 

how to display list of all the duplicate contact record on vf page ?

Hello,
i am not able to display duplicate record on vf page.
plz help
Lokeswara ReddyLokeswara Reddy
Hi Gagan,

Do you have the set of comination fields for identifying duplicates from Contact object. 
If yes, here you go
https://success.salesforce.com/answers?id=90630000000grGTAAY
 
Naval Sharma4Naval Sharma4
Hi Gagan,

Please see the below code.
VF Code
<apex:page controller="DuplicateContactsController">
    <apex:pageMessages escape="false"></apex:pageMessages> 
    <apex:form >
        <apex:pageBlock title="Duplicate Contacts">
            <apex:pageBlockTable value="{! contacts}" var="contact">
                <apex:column headerValue="Name" value="contact.Name"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Controller
public without sharing class DuplicateContactsController{

     public DuplicateContactsController(){}

     public List<Contact> getContacts(){
     
          List<Contact> contacts = new List<Contact>();
          for(Contact con : [SELECT MIN(Id) oldest, COUNT(Id), AccountId accId, Name FROM Contact WHERE AccountId != null AND Name != null GROUP BY AccountId, Name
HAVING COUNT(Id) > 1 ORDER BY COUNT(Id) DESC LIMIT 1000 ]){
               contacts.add(con);
          }
          return contacts;
     }
}

Please let me know if it works for you.

Thanks,
Naval

 
gaganSFDCgaganSFDC
Naval Sharma 4
Compile Error: Loop variable must be an SObject or list of AggregateResult

It shows this error and not able resolve it. plz help