- We needed a way to alert a user of a duplicate when creating a new record and when editing an existing record to meet values where we would consider it a duplicate.
Field Types we want to match on:
- Request Category (Picklist - Controlling Field)
- MatterId (lookup to Matter obj - Managed Package field)
- Request Type (Picklist - Controlled by Request Category / Managed Package field)
- Facility (lookup to Role obj - Managed Package field)
- StartDate (Date - Managed Package field)
Because of the limitations to the fields available for selection with Match Rules, we could not select all necessary Match criteria. Most of the fields listed above are through the Litify Managed Package. However, I can confirm there is also a Text(255) field from this same Managed Package that IS available for selection in the Field dropdown for a new Matching Rule, so I'm not sure if being in a Managed Package has relevance.
We created a Duplicate Rule that runs only when:
- Record Type = 'General Request' OR 'Shared Services Request'
- AND Request Category = 'Medical Information'
We created a Match Rule for that Dupe Rule that checks a text field we're filling with the values from the criteria noted above. This match rule is set to Block users on Create and Edit for EXACT matches on this Text field.
Lastly, we created a Text field (Length:250) and a Before-Save Flow that runs if any of the criteria fields are changed and either fills/updates or clears the text field based on whether the criteria are met.
- Users are receiving the Duplicate error for records we would not expect to be duplicates, based on the criteria. Reviewing the Match_Criteria_Med_Info__c field on the records Salesforce Dev Console returns as duplicates shows this field does not match what the record being created will have set for that value.
- User attempts to Create New Request Record and receives Duplicate Error
- Debug Log shows Before-Save Flow Runs and Assignment to Match_Criteria_Med_Info__c field will be something like:
Medical Information - MatterId:aaaaa - RequestType: Medical Records - FacilityRole:fffff - StartDate:2023-07-01
- Then, Debug Log shows returned Duplicate Error listing record Ids.
- Checking record Ids shows records returned as Duplicates do not have a matching Match_Criteria_Med_Info__c field. Match_Criteria_Med_Info__c field was something like:
Medical Information - MatterId:aaaaa - RequestType: Medical Records - FacilityRole:ggggg - StartDate:2023-08-01
The records the SF Error is returning as duplicate records do seem to all belong to the same related Matter record, but the additional criteria fields (that we are using to fill the Match Criteria text field) do not match.
I've also run a test attempting to manually set the Match Criteria text field to a value that both matches and does not match another Request record's Match Criteria text field. In this scenario, the Before Save flow does not run, and the results are consistent with when the flow does run (Duplicate Rule fires and returns as though there is a match when the Match Criteria text field strings do not appear to match).
Is there a limitation to the number of characters Duplicate Rules check when using Text fields to set a Match Rule?
I don't believe we're hitting any of the issues noted in 'Things to Know About Duplicate Rules' (we've confirmed Users have FLS access to the Match Criteria field), and 'Matching Methods Used in Matching Rules' notes for Exact Matches
The exact matching method looks for strings that exactly match a pattern... You can use the exact matching method for almost any field, including custom fields.