AnsweredAssumed Answered

Custom Field Type - How to make it searchable

Question asked by Denise Ingram on Sep 24, 2018
Latest reply on Sep 25, 2018 by Denise Ingram

I have added a custom field type (Clickablephonefield) per the instructions at http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_8.1/Cookbook/Creating_Custom_Fields/ .

It's a phone field with a clickable icon next to it....

 

I can successfully create a new field of type Clickablephonefield through studio.  I named it phone_test  I can also add it to a module.  I picked the Accounts module and I see the clickable icon next to the number.

 

However, I have missed something on the enabling searching and filtering functionality.  As you can see below, the "Full Text Searchable" option does not appear in Studio > Accounts > Fields 

 

Also, when I check /cache/modules/Accounts/Accountvardefs.php, I see that unified_search is set to 'false' and there is nothing set for the 'full_text_search" array.

 

I have extended php class TemplatePhone with file custom/modules/DynamicFields/template/Fields/TemplateClickablephonefield.php to set the type and support_unified_search variables in the constructor....

function __construct()
{
$this->type = 'Clickablephonefield';
$this->supports_unified_search = true;

$type_string = (string)$this->type;
$converted_search = ($this->supports_unified_search) ? 'true' : 'false';
$GLOBALS['log']->fatal("TemplateClickablephonefield - type: " . $type_string);
$GLOBALS['log']->fatal("TemplateClickablephonefield - unified search: : " . $converted_search);

}

 

I do see the logs come out with supports_unified_search set to true, but it shows up in the vardefs as false.

 

I've included my operators.php and SugarWidgetFieldClickablephonefield.php as those were the two files identified in the instructions as enabling searching capabilities.

 

custom/clients/base/filters/operators/operators.php

<?php

require 'clients/base/filters/operators/operators.php';

$viewdefs['base']['filter']['operators']['Clickablephonefield'] = array(

'$contains' => 'LBL_CLICKABLEPHONEFIELD_OPERATOR_CONTAINS',
'$not_contains' => 'LBL_CLICKABLEPHONEFIELD_OPERATOR_NOT_CONTAINS',
'$equals' => 'LBL_CLICKABLEPHONEFIELD_OPERATOR_IS',
'$starts' => 'LBL_CLICKABLEPHONEFIELD_OPERATOR_STARTS_WITH',

);

 

custom/include/generic/SugarWidgets/SugarWidgetFieldClickablephonefield.php

<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once 'include/generic/SugarWidgets/SugarWidgetFieldphone.php';

 

class SugarWidgetFieldClickablephone extends SugarWidgetFieldPhone
{

}

 

No logs are coming out in the console, apache, php or sugarcrm logs.  

 

Any pointers would be greatly appreciated.

 

Thank you,

 

Denise

Outcomes