The global search returns results with fields such as “Name”, “Date Created” and “Search Score”.
How do I remove a field (e.g. Name) from the global search results?
I believe Global search uses the module’s list view
Go to admin > studio > module name > Layouts > List View
If you want the fields to remain in the module list view but not the global search view I think custom coding would be required
Thanks Taufique for your kind reply.
I don’t think Global search uses the module’s list view.
Because the module’s list view has so many more fields that do not appear in the result of Global search.
Could other member in this forum second that custom coding is required?
i’ve just found out how to change the display layout of the Global Search (Unified Search).
I don’t know if this is the best way to do it (because it is NOT upgrade safe), but it works for now.
File to edit: suitecrm/modules/Home/UnifiedSearch.php
Here you can find the
tags are for the labels in the table header. You can display labels from other modules as well, for example I am showing the Account Name of the Leads Module:
Right under the |
tags is the PHP-Code for the search results in the table. Always make sure that the number of the | tags above match the | tags here. Now it gets a little complicated. First i tried to just duplicate a line and rename the variable to the field i want to output, but in my case that didnt work. So I copied the PHP function getRecordSummary(SugarBean $bean) { … } and altered the content, to get the Field i like to output. The function for “Account Name” of the Leads Module now looks like that (i placed it right above the function getRecordSummary):
As you can see, it’s nearly the same function as getRecordSummary, but i made the “if” to get only the field account_name out of the existing array. Then i created the variable $account_name, and returned it. When you scroll down a bit, you can find a section, where the $newHit variables are created. I added mine like this:
Now back in the PHP-Code where the |
tags for the results in the tables are generated, I added my field like this: <?php if($hits){ foreach($hits as $hit){ echo " | ||
---|---|---|---|---|---|---|
".$hit->label." | " ."".$hit->account." | " //this is my custom field ."".$hit->name." | " ."".$hit->summary." | " ."".$hit->date_entered." | " ."".$hit->date_modified." | " ."".getScoreDisplay($hit)." | " ."
".translate("LBL_SEARCH_RESULT_EMPTY","AOD_Index")." | "; } ?>
For any who is seeking an Enhanced way of searching, please have a look.
https://store.outrightcrm.com/product/enhanced-global-search/
Is it possible to add this module in Elastic Search?
Do you mean my extension “Faster global search” ?