Leveraging search kit from deduper

Published
2021-04-22 18:31
Written by

The duper extension provides a bunch of tools to help with deduping. In this blog I’m going to describe a way that I am now using search kit in the deduper to help make one of those tools more useful.

A key focus of deduper is to resolve conflicts between potentially duplicate contacts. For example if we find all people with the same last name and same street address we will have a mix of genuinely different people and people who are the same. CiviCRM provides the concept of a safe merge - either individually or in a batch we can ‘safe merge’ contacts and if there are no conflicts they will merge.

However, a lot of the time this stumbles on false conflicts ‘José’ vs ‘Jose’ for example. The deduper is able to use it’s diacritic handler to determine that is not a real conflict (and prefer ‘José’) since we can use code functions to compare various language specific characters. But, the only way to know that ‘Ted’ is a nickname of ‘Edward’ is by having some sort of table of equivalent names. This table is included in the deduper extension and is populated as people use the extension to dedupe.

Once saved as a nick name then, depending on the configuration chosen, the nick name might be put in the nick name field, with the non-nick name kept. A future batch script would resolve that contact automatically.

However, until this week the names that went into that table were not visible anywhere in the UI. Enter Search kit. By adding a managed entity to the extension for a saved search and saved search display I was able to add a search display for this table with the ability to delete and edit in place the existing rows by adding a mgd file

The process is pretty simple - create the entities you want and copy them to an mgd file. However, a few notes for anyone wanting to add search displays to an extension

  1. Any entities you want to expose must have a v4 get api
  2. Since search kit is a v4 api and the managed entities were written for v3 you need civicrm 5.38 or a version of civi patched with this change and you need to NOT permit the managed entity frame work to manage beyond insert 
  3. This a real ‘arg’ - search kit is being renamed so this line will need updating soon!
  4. I hit this when I tried to use afform to make it possible to add new rows. I actually wasn’t sure if I wanted the ‘add’ action outside the deduper form so I left it at that point.