Adding a sorting option

In the built in search engine there is an option to “Sort As.” It has almost
every catagory you need to sort by, but it would really be helpful to be able
to sort by “Requestor.” How would I add this “Sort By” option to the list in
the search section? We get a lot of repeat emails since most of them are
automated emails coming from the same computers.

Thanks,

Matt Pressley

In the built in search engine there is an option to “Sort As.” It has almost
every catagory you need to sort by, but it would really be helpful to be able
to sort by “Requestor.” How would I add this “Sort By” option to the list in

‘Not Easily’.

The default fields that you can sort on derive from @SORTFIELDS in
lib/RT/Tickets.pm , which are, surprisingly enough, Column names in the
Tickets table.

( If you are feeling bored, you can add an extra OPTION in
WebRT/html/Elements/SelectTicketSortBy with a stray Tickets Column name )

If you want to sort on Columns outside the Tickets table ( Requestors hide
out in the Watchers table for instance ), you would need to modify
lib/RT/Interface/Web.pm ProcessSearchQuery() to perform a join of the
Tickets and Watchers table, then sort that way.

A few quick tests in this vein in WebRT/html/Search/Listing.html (before
the RedoSearch call) produces a few error messages in my debug logs, and
no discernable result. I suspect I’m calling the Join incorrectly as I
can see the SQL query in the logs with ’ ’ where the second table in the
join should be.

My code snippet so far (which may serve to put you on the right track) is
below. I’d suggest looking at putting this in an ‘Advanced’ search (ie,
/Search/Advanced.html, using Listing.html as a base) whilst debugging.

Regards,

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B                      Operations

– commented code snippet from WebRT/html/Search/Listing.html

my $watchers_alias = $session{‘tickets’}->NewAlias(‘Watchers’);

$session{‘tickets’}->Join( ALIAS1 => ‘main’,

FIELD1 => ‘id’,

ALIAS2 => $watchers_alias,

FIELD2 => ‘Value’);

$session{‘tickets’}->Limit( TABLE => ‘Watchers’,

FIELD => ‘Scope’,

VALUE => ‘Ticket’);

#$session{‘tickets’}->Limit( TABLE => ‘Watchers’,

FIELD => ‘Type’,

VALUE => ‘Requestor’);

#$session{‘tickets’}->OrderBy( TABLE => ‘Watchers’,

FIELD => ‘id’,

ORDER => ‘ASC’ );

$session{‘tickets’}->RedoSearch();