Modify quick search dropdown for products

Could someone give me some pointers on where I need to look to modify what is shown on the autocomplete dropdown for products?

We have multiple products with the same name, but different category tree.

I need to show the hierarchy with the product as we type, it seems that it is something to do with ‘sqs’ but I can’t find any documentation on how to create
my own, or how to modify the response.

The first issue is - is that dropdown handled by your browser, or by SuiteCRM? If you type a value that you’ve never entered before, does it auto-complete?

Yep, it is definitely a suiteCRM thing - it is the quicksearch functionality.

Have a look here

https://github.com/salesagility/SuiteCRM/blob/master/modules/AOS_Products_Quotes/line_items.js

And follow that QSFieldsArray into

jssource/src_files/include/javascript/quicksearch.js

Note that I don’t really know what I’m talking about, I am just using my code searching skills :slight_smile:

Good luck, please share your findings, if you are able to solve it…

Oh, and are you using XDEBUG and an IDE? That really helps for this sort of thing…

We actually have the same issue. I think the ideal solution would be the user inputs the category (with either a dropdown or quicksearch box) and then the product field quicksearch is filtered against that.

Our workaround is adding the product category in the popup for selecting a product. You could also show that category in the line items if you wanted. This basically means the quicksearch isn’t used.

More on quicksearch: http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Module_Framework/Metadata/Examples/Adding_QuickSearch_to_a_custom_field/

1 Like

Nice link, I learned something new! :slight_smile:

I ended up creating a custom quicksearch.js that adds the

String formatResult ( oResultItem , sQuery )

method to the YUI autocomplete,
with some code that checks for a couple of custom functions and then calls them if they exist.
That way in line_items.js (any anywhere else) I can set the following in the sqs_objects:


"render_result_heading": function (item) {
    return item[8];
},
"render_result_label": function (item) {
    return item[0];
}

and change what and how is returned in the quicksearch.

1 Like