What are the capabilities of duplicate rules when lookups/MasterDetail fields are involved in the matching rules. We can certainly detect duplicates using combination of other primary data type fields.

Can I make use of duplicate rules to maintain a one to one relationship between two objects(when I create another child with the same parent -> recognise it as a duplicate)?

Is it possible to use it, to detect a combination of a lookup field and some other field as a duplicate - ex- I want to prevent two contacts under an account with the same first name.

How about preventing duplicates when more than one lookup fields are involved in the criteria i.e. Prevent opportunities with the same name being created under the same parent Account and Contract?

Thanks in advance.

  • I think I answered something like this here: salesforce.stackexchange.com/a/115212/2602
    – cropredy
    Commented Apr 15, 2016 at 0:26
  • @cropredy Thank you. It was very helpful. So we could conclude that we cannot use foreign key/lookup fields in duplicate management directly. If required we need to create a custom field that holds the ID and then populate it using a trigger itself(is before/after fine?). Then use the field directly for duplicate management. Hope I received the message right. Thanks
    – Prajith
    Commented Apr 15, 2016 at 6:24
  • Yep. You understood correctly
    – cropredy
    Commented Apr 15, 2016 at 15:16

1 Answer 1


Use the following logic If its master detail create a rollup summary field of count of records The moment you create a child record,on the before update trigger. query for the this rollup value on parent ,if =1 then ,dont allow child record. For lookups ,you need to store the parent record id in the child when you create a lookup,create a trigger ,create a aggregator list to check for more than one record ,grouping by master record id

  • We could proceed with the rollup summaru on child COUNT + a validation rule that prevents child record creation if the value in this field is greater than 1. Am looking for the capability on duplicate rules when lookup fields are involved. Thanks for your suggestion.
    – Prajith
    Commented Apr 14, 2016 at 13:17

You must log in to answer this question.

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