One key requirement of good Data Quality is a good duplicate prevention and merge process. Salesforce has introduced very powerful mechanisms like Duplicate and Matching-Rules for all SObjects. Unfortunately the full UI support and merge process seems currently only available for Leads, Contacts and Accounts. I'm asking for the roadmap in this question.
We actually need these features for other standard and custom objects.
Because I wasn't able to get any hints about the roadmap yet, we are trying to create the missing UI by using the DuplicateRecordItem
. During that endeavor we run into unexpected issues or we are doing something wrong.
The following examples are based on Account
to point out the issues and compare things to the standard UI. But the problems are the same for the other SObjects, where a standard UI is missing.
Scenario
I've set up very simple Duplicate and Matching rules for Account:
- it should fire on create and on change
- it matches the Name field (exact match)
Now with the Standard Lightning Component "Potential Duplicates" everything works fine:
- Example 1
- If I create one Account called "abc" and an other one called "abc" it gets reported as dupe.
- If I then rename one of these accounts from "abc" to "abc1" it'S no longer shown as dupe - fine, too!
- Example 2
- also if you first create the accounts "def" and "def1" and later rename "def1" to "def", a duplicate will be reported. Super fine and correct!
But if I query for DuplicateRecordItem
- I still get the duplicate after giving abc1 is distinct name in Example 1
- and no match for the two "def"s in Example 2.
To query the DuplicateRecordItem
's, I use
SELECT Id, DuplicateRecordSetId, IsDeleted, Name, RecordId,
CreatedDate, CreatedById, LastModifiedDate, LastModifiedById
WHERE RecordId = 'YOUR_DUPE_RECORD_ID'
It looks like DuplicateRecordItem
gets only updated/created on create of the SObject for which the duplicate-rule exists (Account
in these examples). In the first example, the DuplicateRecordItem
-record will be created, but exists forever and in the second example, it will never be created...
It looks like that in action:
The first component in the right panel with the yellow icon is the Salesforce Standard "Potential Duplicates" and the one below with the pink icon is our custom compo based on DuplicateRecordItem
and the query shown above.
Note that in our custom DuplicateRecordItem
-based version, there is still a duplicate reported called "elastify GmbH & Co. KG". As you can see in the Account History, the current record was created as "elastify GmbH & Co. KG" and was later renamed to "elastify GmbH & Co. KG - Science Park". The Standard Lightning Component is getting that update, but DuplicateRecordItem
seems blind for it.
Questions
- Am I doing something wrong here?
- If not, why is that so? Bug or feature?
If I don't make a mistake here, I would say that in the current condition the DuplicateRecordItem
is practically useless.
As far as I see, DuplicateRecordItem
is the only viable approach to create a custom lightning component for that purpose. Any other approach is welcome, too.