AnsweredAssumed Answered

Problems customizing the Search form in the Contacts module to check for duplicates

Question asked by Mukta Patel on Mar 13, 2014
On Contacts module I have included three checkboxes to find duplicates on 1) name 2)number 3) email address

In custom/modules/Contacts/metadata/Searchfields.php have added following code

$searchFields['Contacts']['chk_name'] = array(
'query_type' => 'format',
'operator' => 'subquery',
'subquery' => 'SELECT p1.'id' FROM 'contacts' as p1 INNER JOIN (SELECT first_name,last_name,count(*) as rows FROM 'contacts' where deleted = 0 GROUP BY first_name,last_name HAVING count(rows) > 1) as p WHERE p.'first_name' = p1.'first_name'and p.'last_name' = p1.'last_name'',
'db_field' => array(
'id',
),
);   


$searchFields['Contacts']['chk_phone'] = array(
'query_type' => 'format',
'operator' => 'subquery',
'subquery' => 'SELECT p1.'id' FROM 'contacts' as p1 INNER JOIN (SELECT phone_mobile,count(*) as rows FROM 'contacts' where deleted = 0 GROUP BY phone_mobile HAVING count(rows) > 1) as p WHERE p.'phone_mobile' = p1.'phone_mobile'',
'db_field' => array(
'id',
),
);

The problem is I want to search duplicates both on name & number.Above is valid only when either name or number is selected.

If both are selected how & where should it be managed?

Outcomes