How to add Email field as duplicate check in Contacts module on Lead Conversion Process?

Hi Everyone,

We had a requirement in Lead Conversion Process in SugarCRM 9.x . We are working on 9.x Sugar Professional  Edition. Basically when we convert the Lead on Convert page of Contacts module by default first name and last name will be as default check in Contacts Page. Now I would like to check based on the Email field entered in the Leads module. I have tried extending the vardefs.ext.php from Contacts module to custom path and tried. But when I tried to  do this I am getting an error on Lead Conversion like "Unable to Convert Lead" error . I clearly understood that my custom code is breaking the Default functionality and  I tried removing the code and changed a bit and retried giving repair and rebuild. But due to some mistake in my code second time I am not able to open the instance also. Can someone try helping me to figure out the error and resolve the issue. I dont see any errors logged in sugarcrm.log or error.log.

This is code I have added in the custom/Extension/modules/Contacts/Ext/Vardefs/duplicate_check_email.php

<?php

$dictionary['Contact'] = array(

'duplicate_check' => array(
'enabled' => true,
'FilterDuplicateCheck' => array(
'filter_template' => array(
'$or' => array(
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')),
)
),
array('email1' => array('$starts' => '$email1')),
)
),
'ranking_fields' => array(
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',
),
),
),
),
);
?>

Could anyone suggest how to resolve the issue and add email as duplicate check in Contacts Page on Lead Conversion process in Sugar 9.x Professsional Edition. Thanks in Advance.

Parents Reply Children
  • Hi Andre Lopes,

    Can you please be more specific, do you mean to say the above code is correct and  just to replace array('email' => array('$starts' => '$email')), in place of email1 or can you please suggest me what is the error in the above code.

    Thanks in Advance.

  • Hi , 

    I have implemented this logic in one of our recent project requirements and it worked without any issues in Sugar 9.0.1 Professional edition. I believe you have to include the email parameter inside an array in the code. Can you please try with below snippet of code in the same path and let me know if it works for you or not. Hope it helps for you.

    The path where you have to place the below code - custom/Extension/modules/Contacts/Ext/Vardefs/duplicate_check_email.php

    <?php
    $dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'] = array(
    array(
    array(
    '$or' => array(
    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'
    )
    ) ,
    )
    ) ,
    array(
    'email1' => array(
    '$starts' => '$email1'
    )
    ) ,
    )

    ) ,

    ) ,
    );

    ?>

  • Why use starts on an email address check? Would one not want to check for an exact match on the email address?