HOWTO: Add custom fields into the global search

bsoremsugar —  April 29, 2011 — 20 Comments

As posted a few weeks back on this blog, we’ve added support from the UI to add custom modules into the global search in Sugar 6.2. But one other problem people have seen, as posted in this forums post, is that if you add custom fields to a module those are not able to be added to the global search thru the UI. But there is a way to do this thru some custom coding, as we’ll see here below.

The key to making this happen is to set the ‘unified_search’ parameter for the field. To do this, add new file under the custom/Extension/modules/YOUR_MODULE/Ext/Vardefs/customGlobalSearchFields.php directory with the following contents:

Then, you need to add a search definition for the file, which you can specify in the custom/modules/YOUR_MODULE/metadata/SearchFields.php file as shown below

Then do a quick rebuild and repair, and the field should now be available to be searched thru the global search.

20 responses to HOWTO: Add custom fields into the global search

  1. 

    Anyway to get results to show up in the search preview window as well? This only works if I go to Full Form.

    • 

      I seeing it appear in both the search popup screen, as well as the full screen form. Which version of Sugar are you using?

      • 

        I was using 6.1.1 and had applied a similar workaround to add a custom field to global search that was in the accounts module. I’ll get a 6.2 box setup and test later. Thanks.

  2. 

    One thing to note here is that for the SearchFields.php file, the ‘YOUR_MODULE’ value is the plural form.  I looked at the out of the box default SearchFields.php files and they use the plural form.  So for example, with the Accounts module you’d use “Accounts” for SearchFields.php, but “Account” for the vardef customization.

  3. 

    This field not work in 6.3.0 version of sugarCRM

    • 

       It does work in 6.4.4. Be sure to make sure you are putting the right module name in the YOUR_MODULE piece above, just as the commenter above mentions.

  4. 

    It’s not working, I try it in project:

    File ‘D:wwwsugarcrmcustomExtensionmodulesProjectExtVardefscustomGlobalSearchFields.php’  as that line :
    $dictionary['Project']['fields']['no_reference_projet_c']['unified_search'] = true;

    And file ‘D:wwwsugarcrmcustommodulesProjectmetadataSearchFields.php’ as that line at the begining :
    $searchFields['Projects']['no_reference_projet_c'] = array( ‘query_type’=>’default’);

    and I tried
    $searchFields['Project']['no_reference_projet_c'] = array( ‘query_type’=>’default’); too

  5. 

    Has this been verified to work on version 6.5.x ?

  6. 

    I tried in 6.4.4 CE Edition and it’s not searching.

  7. 

    Confirmed working in 6.5.14. Thanks to Fred for the correction on module naming!

  8. 

    Confirmed working in 6.5.14. Thanks to Fred for the information on module naming.

  9. 

    This does not seem to work in v7.x

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s