I'm writing some code to search for duplicates for a list of contacts. I need to be able to map the duplicates to the corresponding original/master contact. I haven't been able to find any documentation for that in the Datacloud docs. All the sample code I see assumes that there is only one contact in the list.
My code (con ids have been changed):
List<Id> conIds = new List<Id>{'00332QQQ026x7IX', '0036WQQ00od74b'};
Map<Id, Contact> dupeCons = new Map<Id, Contact>();
for(Datacloud.FindDuplicatesResult fdr: Datacloud.FindDuplicatesByIds.findDuplicatesByIds(conIds)){
for(Datacloud.DuplicateResult dr: fdr.duplicateresults){
for(Datacloud.MatchRecord m: dr.matchResults[0].getMatchRecords()){
Sobject obj = m.getRecord();
if(VF.getObjectNameById(obj.Id) == 'Contact'){
dupeCons.put(obj.Id,(Contact)obj);
}
}
}
}
I'd really like to have a Map so that the first key would be the original contact id, and each one would have a map of duplicates associated with it.
Something like:
Map<Id, Map<Id, Contact>