Thursday, 7 February 2013

Duplicate Alarm

Today I came across an interesting post on SugarCRM Forum which says give an indication next to phone number if it is found to be repeated over various Contacts.

Lets do it!

Step 1: Create a process_record logic hook in custom/modules/Contacts/logic_hooks.php
Add following code in it. If the file already exists, add following lines.

<?php
$hook_array['process_record'][] = Array(1, 'Check Dup', 'custom/modules/Contacts/checkDup.php','checkDupC', 'checkDupF'); 

Step 2: Lets add logic. Create a file checkDup.php under custom/modules/Contacts folder and add following code.

<?php
class checkDupC{
    function checkDupF($bean){
        $sContacts = $bean->db->query('SELECT contacts.id FROM contacts WHERE contacts.phone_work = "'.$bean->phone_work.'" AND contacts.id <> "'.$bean->id.'" AND contacts.phone_work IS NOT NULL', true);
        $bFound = false;
        while($aContacts = $bean->db->fetchByAssoc($sContacts)){
            if(!empty($aContacts['id']))
                $bFound = true;
        }
       
        if($bFound){
            $bean->phone_work = $bean->phone_work."&nbsp;".SugarThemeRegistry::current()->getImage('no');
        }
    }
}

And refresh the list view. You should have next to the duplicated phone numbers.

Hope you find the blog post helpful.

Please feel free to leave comments.

1 comment:

  1. Thanks for such social platform which give us variety of idea to explore ourself technically .This exposure give benefits to everyone to fit or to survive in global market which is very essential in the global era.
    Time Attendance System

    ReplyDelete

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