Wednesday, 11 June 2014

Disable duplicate check on fields in Sugarcrm 7

Out of some requirements and many requests on forum about how to Disable duplicate check on fields while saving the record.


Lets look at the scenario of what we are trying to achieve. For an example we are taking Contacts module and removing its "First Name" and "Last Name" field from duplicate check.

If you go to the Vardefs file you will see a "duplicate_check" array, within that you need to remove the "first_name" and "Last Name" field from "filter_template" array.
Now lets take a look of how we can do that upgrade-safe way.

Extend the contact's Vardef file at
custom/Extension/modules/Contacts/Ext/Vardefs/duplicate_check_disable.php

And then redefine the "filter_template" array in that. See the below example to get more idea.
This will remove the duplicate check on "First Name" and "Last Name" when you try to save contact's record.
<?php
$dictionary['Contact']['duplicate_check']['FilterDuplicateCheck']['filter_template'] =
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')),
        )
    ),
);
?>

After this changes go to Admin -> Repair and perform "Quick Repair and Rebuild". Go back and try saving contact records and check for the duplicates on First Name.

We hope this blog has helped you to some extent. Feel free to ask question or get back to us.

 

No comments:

Post a Comment

Urdhva Tech Pvt. Ltd. Powered by Blogger.

Urdhva Tech

My photo
SugarCRM Consultants Contact us at contact@urdhva-tech.com Skype : urdhvatech

Search This Blog

Stay connected Socially

     

Total Pageviews

Popular Posts