Customize search popup window

Hello,

following this tutorial tutorial I’ve just added a field in the Advanced search of Contacts, but now I also need to add the same field in the search popup window in Target Lists -> Contacts -> Select.

Unfortunately in Studio I can only see this field in Contacts -> Layouts -> Search -> Advanced search but not in Contacts -> Layouts -> PopupView -> Popup Search.

So far I’ve only modified/created the following files:

custom/Extension/modules/Contacts/Ext/Vardefs/account_type.php (new)
custom/modules/Contacts/metadata/SearchFields.php (copied from modules/Contacts/metadata/SearchFileds.php and modified)
custom/modules/Contacts/metadata/metafiles.php (new)

Shall I modify other files in order to be able to add that field on the popup search window too?

Many thanks in advance

Greetings

mal

1 Like

Hi,

What kind of field did you create?
Did you create it in studio and then edit files to add it to the Advanced search, or did you create the field via the code?
If you run a Quick Repair & Rebuild, do any changes show at the bottom of the page, asking to be executed?

Hi John,

I created the field via the code. After creating (or modifying) the following three files:

custom/Extension/modules/Contacts/Ext/Vardefs/account_type.php (new)

<?php
 $dictionary["Contact"]["fields"]["account_type_search"]= array(
   'name' => 'account_type_search',
   'vname' => 'LBL_ACCOUNT_TYPE_SEARCH',
   'query_type' => 'default',
   'source' => 'non-db',
   'type' => 'enum',
   'options' => 'account_type_dom',
   'studio' => array('searchview'=>true,'visible'=>false),
);

custom/modules/Contacts/metadata/SearchFields.php (copied from modules/Contacts/metadata/SearchFileds.php and added the following code)

'account_type_search' => array (
            'db_field' =>
            array (
              0 => 'id',
            ),
            'query_type' => 'format',
            'operator' => 'subquery',
            'subquery' => 'SELECT accounts_contacts.contact_id FROM accounts_contacts
                           INNER JOIN accounts ON accounts.id = accounts_contacts.account_id AND accounts.deleted = 0
                           WHERE accounts_contacts.deleted = 0 AND accounts.account_type IN ({0})',
        ),

custom/modules/Contacts/metadata/metafiles.php (new)

<?php
$metafiles['Contacts']['searchfields']='custom/modules/Contacts/metadata/SearchFields.php';

and after a Quick Repair & Rebuild, the new field was available in the list of hidden fields for the Advanced Search and now I’m able to filter the Contacts by their Account name.

The Quick Repair & Rebuild didn’t ask me to execute any change.

The problem is that this field is only available in the Advanced Search, It should be also added to the Popup Search but there it’s missing. It’s also missing from the main field’s list in Contacts -> Fields.

I’m sure I missed something, but I’m very new to SuiteCRM and I wasn’t able to find the error… is this the right process to add this kind of field?

Thanks

I found this solutions, it works but I don’t know if it is the right method to add the field to the popup search:

I added the following line to custom/modules/Contacts/metadata/popupdefs.php, in the ‘searchdefs’ array:


'searchdefs' => array (
...
/* I added this line */
'account_type_search' => array('name' => 'account_type_search', 'type' => 'enum', 'label' => 'LBL_ACCOUNT_TYPE_SEARCH',),

After a Quick Repair & Rebuild the field is visible in the Popup Search for Contacts. In Studio is visible but only in Contacts -> Layouts -> Search -> Advanced search and in Contacts -> Layouts -> PopupView -> Popup Search, but not in Contacts -> Fields.

Did it work out for the Popup?