0

Scope:

  • 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'

Dupe Rule Photo



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.

Match Rule Photo



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.

Text Field

General Flow Overview

The Issue:

  • 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.

Ex:

  • 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.

2
  • 1. With the exception of date field, the rest of your fields are natively supported by Matching Rules. (Assuming lookups are not auto-numbered). 2 Debug without the flow.
    – identigral
    Aug 5 at 0:03
  • @identigral - I had thought they were natively supported by Matching Rules as well. However, the fields are not available under the Field selection for a new Match Rule. I've added more detail on the fields to the post. I Debugged by manually setting the value for the Match Criteria text field and can confirm even w/o the flow running, the Duplicate Error returns when the text fields do not appear to be matches (different Start Date values). Aug 7 at 13:25

1 Answer 1

0

After speaking with Salesforce Support, it has been determined this is a 'known issue' and Text fields used in Matching Rules only look at the first 100 characters of the field. Reducing the field to less than 100 characters confirmed dupe rule worked as expected.

Workarounds:

  • Reduce characters in the text field to under 100 characters
  • Create supplemental text fields and split the criteria data between the two and ensure each field holds less than 100 characters

Additional Solve:

  • Avoid the Duplicate/Match Rules and use a Before-Save flow to query and evaluate criteria
  • If a Match is found, you can use a solution similar to what's suggested in this comment to throw a validation error.

You must log in to answer this question.

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