Add Custom Field to Global Search

I’ve been trying to add some custom fields to be included in the Global Search but I am not having any success. I have AOD turned off because I prefer the basic search.
I’ve followed the instructions here: https://developer.sugarcrm.com/2011/04/29/howto-add-custom-fields-into-the-global-search/
but it doesn’t work for me.
I’ve found that if I update \cache\modules\unified_search_modules.php it works perfectly, but anytime a Quick Repair / Rebuild is done, that file is rebuilt and the custom field is no longer on there. So I just need to know how to make it so the custom field is added to that file whenever it is rebuilt.

Here are my files:
\custom\Extension\modules\Opportunities\Ext\Vardefs\sugarfield_phone_c.php

<?php
$dictionary['Opportunity']['fields']['phone_c']['inline_edit']='';
$dictionary['Opportunity']['fields']['phone_c']['labelValue']='Phone Number';
$dictionary['Opportunity']['fields']['phone_c']['unified_search']=true;
 
 ?>

and in \custom\modules\Opportunities\metadata\SearchFields.php I have added to the array: $searchFields[‘Opportunities’] = array (

'phone_c' => 
  array (
    'query_type' => 'default',
  ),

Any help would be greatly appreciated.

For anyone who comes across this, I have FINALLY figured out the solution. All that was needed was to add ‘force_unifiedsearch’=>true to the SearchFields.php file and now that field is added to unified_search_modules.php every time it is rebuilt.

\custom\modules\Opportunities\metadata\SearchFields.php

'phone_c' => 
  array (
    'query_type' => 'default',
	'force_unifiedsearch'=>true
  ),
3 Likes

I’m trying to get any custom field in a custom module to work. I tried a textfield, comments textarea, relationship field. So far unsuccessfully. What am I missing?

My changes to show up fine in the file \cache\modules\unified_search_modules.php. But my global_search tests are all unsuccessful.
Searching by name of the custom module works fine btw.

Do I need to add some extra steps to get custom fields to work for a custom module?