contacts duplicate check

Hi. I'm trying to modify the duplicate check filter for Contacts module.

I'm using the instructions at https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.0/Architecture/Duplicate_Check/

and have added the code below to the location ./custom/Extension/modules/Contacts/Ext/Vardefs/duplicate_check_email_v7_twitter.php

The example removed the 'shipping_address_city' field, I have tried to use the same theory to add the 'twitter' field to test with but as far as I can tell it has made no difference.  

Can any of you see what the issue is please?

<?php

$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck'] = array(
    'filter_template' => array(
        array(
            '$and' => array(
                array('twitter' => array('$starts' => '$twitter')),
                array('first_name' => array('$starts' => '$first_name')),
                array('last_name' => array('$starts' => '$last_name')),
                array('accounts.id' => array('$equals' => '$account_id')),
                array('dnb_principal_id' => array('$equals' => '$dnb_principal_id')),
            ),
        ),
    ),
    'ranking_fields' => array(
        array(
            'in_field_name' => 'twitter',
            'dupe_field_name' => 'twitter',
        ),
        array(
            'in_field_name' => 'account_id',
            'dupe_field_name' => 'account_id',
        ),
        array(
            'in_field_name' => 'last_name',
            'dupe_field_name' => 'last_name',
        ),
        array(
            'in_field_name' => 'first_name',
            'dupe_field_name' => 'first_name',
        ),

    ),
);

Also, would the updated duplicate check happen at the point of entry like it currently does if it matches a name, or is this for the 'Find Duplicates' you can run when in a record?

Thanks
James

Parents Reply Children
  • Thank you for responding and clarifying Jeff. 

    If you don't mind, have I got the following correct? Just so I can see a change working and understand it, I've tried to set it so the twitter field is one possible check, and the rest of the fields mentioned are another. Is the nesting correct, I'm trying to understand how the OR's and AND's ?  Starting the array with OR has thrown me.

    Thanks

    James

    <?php
    
    $dictionary['Contact']['duplicate_check']['FilterDuplicateCheck'] = array(
        'filter_template' => array(
            array(
                '$or' => array(
                    array('twitter' => array('$starts' => '$twitter')),
    
            array(
                '$and' => array(
                    array('first_name' => array('$starts' => '$first_name')),
                    array('last_name' => array('$starts' => '$last_name')),
                    array('accounts.id' => array('$equals' => '$account_id')),
                    array('dnb_principal_id' => array('$equals' => '$dnb_principal_id')),
                     ),
                  ),
                ),
            ),
        ),
        'ranking_fields' => array(
            array(
                'in_field_name' => 'twitter',
                'dupe_field_name' => 'twitter',
            ),
            array(
                'in_field_name' => 'account_id',
                'dupe_field_name' => 'account_id',
            ),
            array(
                'in_field_name' => 'last_name',
                'dupe_field_name' => 'last_name',
            ),
            array(
                'in_field_name' => 'first_name',
                'dupe_field_name' => 'first_name',
            ),
    
        ),
    );