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!

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.

The Problem**

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:

The Solution**

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

To use, copy the following code(s) into a Global JavaScript widget in your (non-Lotus) ZenDesk. This can be found under Settings » Extensions » add widget » Global JavaScript

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.

The Code**

// SEARCH MOD: require all searched words
jQuery("#topquery").submit(function() {
    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(function() {
    jQuery("#topquery").each(function() {
        jQuery(this).append("<input type='hidden' name='by\_updated' value='1' \/>");

Questions? Improvements? Comments are welcome!


Please sign in to leave a comment.