0

We just activated Salesforce's native duplicate management on an existing org. The users are still in classic, so in order to make it really noticeable that there is a duplicate, I'm creating a vf page to embed in the contact detail which will have a list of the duplicates, very similar to how it looks in lightning.

To do so I'm running the following queries in a custom controller:

  1. Call the following code, where contactid is the id of the contact taken from the get parameters:

    thisDuplicateRecordItem = [SELECT Id, DuplicateRecordSetId FROM DuplicateRecordItem WHERE 
                RecordId = :contactId LIMIT 1];
    thisDupRecSetId = thisDuplicateRecordItem.DuplicateRecordSetId;
    
  2. Run the following query:

    SELECT RecordId FROM DuplicateRecordItem WHERE DuplicateRecordSetId = :thisDupRecSetId
    

I would assume that this would give me the same number of results as I get on the page in lightning. I'm developing this in my sandbox which is in lightning for now, and see different results.

I have three contacts that show up as duplicates on each other's pages, but when I enter one of the contact's id in the get param, it doesn't pull any duplicates, and when I enter either of the others, it pulls one.

Why would that be?

1 Answer 1

0

Surprisingly, there is no reliable way to query the duplicates. We need to use the datacloud duplicate methods.

Something like the following:

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);
                    }
            }
        }
} 

You must log in to answer this question.

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