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
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;
}
}
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
Please see the below code.
VF Code
Apex Controller
Please let me know if it works for you.
Thanks,
Naval
Compile Error: Loop variable must be an SObject or list of AggregateResult
It shows this error and not able resolve it. plz help