It's possible to specify on a dedupe rule that 'Contact Subtype' must match. Is there any way of attaching specific values to that, for example, 'and they must both be Student'?

Some of this could be done by having, say, a group of students and a group of teachers, and choosing the students group when I run the rule. I only have this option when running it manually (Find and Merge)- what about for rules I want to be Supervised and Unsupervised?

In this case I want to deduplicate students against students (subject to the other conditions in the rule), but not students against teachers, or teachers against teachers. We are looking to run a survey of a large number of contacts and they tend to object if they receive it several times!

1 Answer 1


You can potentially do this by implementing the hook:


Check: CRM/Dedupe/BAO/RuleGroup.php

to see places where the hook is invoked

  • That looks good. I could watch for $obj->id being the rule ID I want to add to, and $type being 'table', and add an additional query to the array checking the value of (in this case, but any field could be used) the contact_subtype. The rule's threshold would need to be increased to cover the extra query that would not be visible in the interface. This sounds to me like a good idea for an extension if we could afford the time to develop it.
    – DaveFF
    Commented May 6, 2015 at 11:47
  • What I've done for my case, I've put in a gist at gist.github.com/futurefirst/a4e1d4346fa99b50cb8e . This gist also covers something I mentioned on another question where I could not add conditions covering custom fields that are only defined on contact subtypes.
    – DaveFF
    Commented May 6, 2015 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.