I'm trying to de-dup the Contact or Lead in our instance based on 3 collected email fields and 1 customized field let's call it Field A. The rule is gonna be like, if any email cross matched:

E.g. Contact1 Email 1 vs Contact2 Email 1, Contact1 Email 1 with Contact2 Email 2, Contact1 Email 1 with Contact2 Email 3

or Field A matched, it's flag as duplicates.

I'm brand new in Salesforce and I'm really appreciate if someone can solve my question.

  • 1
    welcome to SFSE; please see How to Ask on getting the most from the Community. In your case, you should show what you've tried with your Matching Rules - use edit
    – cropredy
    Dec 30, 2022 at 18:47

2 Answers 2


Unfortunately Salesforce matching rules will not compare one field to a different field (like Email 1 field against Email 2 field), they can only compare the same field across records.


Using Duplicate Rules/Matching Rules; this could be done with 24 custom fields, each managed by a Flow or trigger

You basically have 4 fields that can match against any of four other fields

So, you need 24 compound fields, each of which is a concatenation of the 4 email fields in all the permutations (4 factorial)

  • Custom Field 1 (Text): Email1 + Email2 + Email3 + A
  • Custom Field 2 (Text): Email2 + Email1 + Email3 + A ...

Now you are limited to 5 Duplicate Rules per Object but a given matching rule can have up to 10 (I think) OR conditions. This would give you

Duplicate Rule 1
 Matching Rule 1
   condition Custom Field 1 exact OR
             Custom Field 2 exact OR
             Custom Field 3 exact OR
             Custom Field 10 exact

Duplicate Rule 2
 Matching Rule 2
   condition Custom Field 11 exact OR
             Custom Field 12 exact OR
             Custom Field 13 exact OR
             Custom Field 20 exact

Duplicate Rule 3
 Matching Rule 3
   condition Custom Field 21 exact OR
         Custom Field 22 exact OR
         Custom Field 23 exact OR
         Custom Field 24 exact


  1. This doesn't scale - if you had 5 fields, you get 5! permutations = 120 custom fields and you'll run out of Duplicate Rules
  2. This is considerably simpler if you just want to reject out of hand any dups (record can't be saved -- equivalent to Block in a duplicate rule) by doing the logic in a Before Save Flow or a before insert trigger
  • Scalability aside, I don't understand how the permuted concatenation would help comparing two different fields since the matching rule will only compare the same permutation in the same order for two given records. The custom fields will either all be a match or none.
    – zakinster
    Apr 5, 2023 at 16:44

You must log in to answer this question.

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