Forums/Community/Community tips & tricks

Introducing a script for a quicker ticket search (Zendesk Classic)

Lyman Benton
posted this on April 04, 2012 15:32

Preamble

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...

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() {
    jQuery("#searchinput").val(jQuery("#searchinput").val().trim());
    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!

 

Comments

User photo
Michael
joyent

Helped me, I was experiencing similar problem, thanks! 

June 01, 2012 13:11
User photo
Jack Bremer
3B Digital

BRILLIANT!!! Thank you :)

August 30, 2012 02:39
User photo
Justin Graves
ensign

We are using the new Zendesk interface.  Any chance this would work there?

March 12, 2013 08:17
User photo
Lyman Benton
visioninternet

Hi Justin,

I checked out the new Agent interface and the search is a bit harder to inject scripts into. (Particularly so because you can no longer sort by "Latest Activity" for some reason! What were they thinking?)

I'll have to go back to the drawing board for now -- right now my team has just gone back to using the old ZenDesk.

I'll edit and post here if and when the new search can be enhanced.

Thanks,
Lyman

March 12, 2013 12:40
User photo
Jennifer Rowe
Zendesk

Hi Lyman, thanks for answering. And thanks for updating the post when/if you create a new solution. Would love to see that. Thanks again!

March 12, 2013 13:40
User photo
Justin Graves
ensign

Lyman-  There is a way to sort the search results in the new Zendesk but it's not very elegant (and not in the quick drop-down where it should really be highlighted).  Anyway- thanks for the reply and I would also be interested if you come up with a solution.

 

Thanks,

Justin

March 12, 2013 15:07