9

I'm getting a really weird behavior from the new Duplicate Catcher in Salesforce. It seems like sometimes, the standard Duplicate Catcher will catch duplicate when doing a bulk operation, but some other times, it won't.

Here's an example where it works (same email, blocking operation if dupe):

Account account1 = new Account(
  Name = 'Sample Company',
  Email__c = 'test@example.com',
  BillingCountry = 'JP'
);

Account account2 = new Account(
  Name = 'Some Different Company',
  Email__c = 'test@example.com',
  BillingCountry = 'JP'
);

insert new Account[]{account1,account2};

Here's an example where it doesn't work (same name - using fuzzy, blocking operation if dupe):

Account account1 = new Account(
    Name = 'Sample Company',
    Email__c = 'test@example.com',
    BillingCountry = 'JP'
);

Account account2 = new Account(
    Name = 'Sample Company',
    Email__c = 'test2@example.com',
    BillingCountry = 'JP'
);

insert new Account[]{account1,account2};

The first scenario seems to work at all time. If I bulkify, add one single record or anything else, it will return an error and prevent from saving - on the UI, Anonymous Apex or through the API.

However, the second scenario doesn't work on bulkify - it will allow users to create dupe records where the name is the same. If I try to do it in two seperate DML requests, the Duplicate Management tool will notify me and prevent from saving, whatever way I used to create that record.


Here's the configuration:

enter image description here

enter image description here

enter image description here

enter image description here


I looked at the documentation and I didn't see any limitation related to that. Have you experienced something alike?


EDIT

It seems like the field was set to unique. Considering this, my conclusion is that duplicate management rules are ignoring duplicate records inside the same transaction.

0

I do not know if this is going to help but you could use some Apex before insert to check for it yourself. I use this function to get the duplicates:

public static List<SObject> checkForDuplicates(List<Contact> contacts){
    List<sObject> duplicateRecords = new List<sObject>();
    Datacloud.FindDuplicatesResult[] results = Datacloud.FindDuplicates.findDuplicates(contacts);
    for(Datacloud.FindDuplicatesResult findDupeResult : results){
        for(Datacloud.DuplicateResult dupeResult : findDupeResult.getDuplicateResults()){
            for(Datacloud.MatchResult matchResult : dupeResult.getMatchResults()){
                for(Datacloud.MatchRecord matchRecord : matchResult.getMatchRecords()){
                    duplicateRecords.add(matchRecord.getRecord());
                }
            }
        }
    }
    return duplicateRecords;
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.