Introducing a script for a quicker ticket search (Zendesk Classic)
When I learned to use search engines, I was always told that including more words will narrow my search.
ZenDesk, however, seems to think the opposite: the more words you include, the more tickets it finds!
- 1 word, 1769 results: https://support.zendesk.com/attachments/token/oa4tnddjytcgkmw/?name=1_word.png
- 2 words, 2563 results: https://support.zendesk.com/attachments/token/ctwm1zbaw0tdhxj/?name=2_words.png
It turns out ZenDesk uses more of an "OR" search, while most search engines use "AND" searches. This means Google ensures nearly all searched words are present in results, while ZenDesk piles on as many results as it can find with at least 2/3 of your words included.
While ZenDesk provides several useful search tips, I had a problem: even after training my support team on advanced search operators for half a year, they avoided searching in ZenDesk unless absolutely necessary.
ZenDesk search tips:
Here are two scripts which narrow search results to require all searched words, and automatically sort by the most recent ticket update. They're not perfect, but our team is finally using the search tool again and quickly finding what they need.
2 words (fixed), 662 results: https://support.zendesk.com/attachments/token/q1p3bxhm9nebej7/?name=2_words_fixed.png
HOW IT WORKS: The code trims any surrounding whitespace, then if there are multiple words, it prepends + signs in front of each word (unless it is inside quotation marks).
CAUTION: This code uses jQuery and has not been tested for every helpdesk. We have not experienced bugs on our ZenDesk however.
// SEARCH MOD: require all searched words
if (jQuery("#searchinput").val().indexOf(" ") > 0) jQuery("#searchinput").val((jQuery("#searchinput").val().indexOf("+") == 0 ? "" : "+") + jQuery("#searchinput").val().replace(/\s+(?!+)(?=([^"]*"[^"]*")*[^"]*$)/g, ' +'));
// SEARCH MOD: default sort by most recent
jQuery(this).append("<input type='hidden' name='by\_updated' value='1' \/>");
Questions? Improvements? Comments are welcome!