AnsweredAssumed Answered

Duplicate check on creation and edit of existing contact record.

Question asked by Usman Saeed on Sep 14, 2014
Latest reply on Jun 23, 2015 by paperless
Hi All,

I want duplicate check whenever a record is saved either new or existing (Sugar Pro: 7.2.2).
The duplicate check criteria is : contact first_name and last_name and (mobile or work_phone or email).
ie. first name and last name should be matched and one of mobile or work phone or emial should matched in order to check for duplicates.

I used the custom/Extension/modules/Contacts/Ext/Vardefs/duplicate_check_disable.php file
and in here my code is : 

$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'][0]['$and'][] = array

('first_name' => array('$equals' => '$first_name'));
$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'][0]['$and'][] = array

('last_name' => array('$equals' => '$last_name'));

$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'][0]['$and'][]['$or'][0] = 
        array(
            'phone_work' => array('$equals' => '$phone_work')
            )
        ;
$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'][0]['$and'][2]['$or'][1] = 
        array(
            'phone_mobile' => array('$equals' => '$phone_mobile')
            )
        ;

$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'][0]['$and'][2]['$or'][2] = 
        array(
            'email1' => array('$equals' => '$email1')
            )
        ;

This is not working as it is only checking first_name and last_name but not going in the other condition.

Also, this works for new records not for existing record.

Business rule is : If an existing contact record is modified and has same first_name, last_name, and (mobile or work_phone or email), do not allow the record to be saved, throw error.


How, can I achieve that functionality. Can somebody, please help?

Thank you,

Usman

Outcomes