07
February

0 Comments | 0 Shares | Urdhva Tech | Tags: ListView

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.
Download attachments:
Comments
  • No Comments Found.
Post your comment