AutoRequestorTicketSearch

From Request Tracker Wiki
Revision as of 16:03, 6 April 2016 by Admin (talk | contribs) (5 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

When creating tickets in RT on behalf of a user, it's often useful to look over the list of tickets in which the user is a requestor in order to avoid duplicates. Opening a tab, moving to the search page and building a new search can however be uselessly time-consuming.

With this simple customisation, upon selecting a Requestor through the autocomplete dropdown on the ticket creation page, a panel will appear on the bottom of the page listing this user's most recent tickets.

In Callbacks/AutoRequestorTicketSearch/Ticket/Create.html/AfterRequestors :

<script type="text/javascript">
    jQuery(document).ready(function(){
       jQuery('form[name=TicketCreate]').after('<div id="auto-requestor-ticket-search" style="clear:both;"></div>');
       jQuery('input#Requestors').autocomplete({
         select:function( event, ui ) {
                 jQuery('#auto-requestor-ticket-search').empty().load("/Helpers/AutoRequestorTicketSearch.html?" + jQuery.param({ UserEmail: ui.item.value }));
         }
       });
     });
  </script>

In Helpers/AutoRequestorTicketSearch.html :

<&|/Widgets/TitleBox, title => "Last 25 tickets for " . $User->RealName &>
% if ($Collection->CountAll() > 0) {
<& /Elements/CollectionList,
    AllowSorting => 0,
    Class => 'RT::Tickets',
    Collection => $Collection,
    ShowNavigation => 0,
    ShowEmpty => 1,
    %query_args,
    &>
% if ($Collection->CountAll() > 25) {
<& /Elements/Submit, Label => loc('Voir tous'), &>
% } % } else { <p><&|/l&>No tickets found.</&></p> % } <%INIT> my $User = RT::User->new($RT::SystemUser); $User->LoadByEmail($UserEmail); my $Query = "Requestor.EmailAddress LIKE '${UserEmail}'"; my %query_args = ( Format => qq{ '__id__/TITLE:#', '__Subject__/TITLE:Subject', '__Status__', '__OwnerName__', '__LastUpdatedRelative__'}, OrderBy => 'LastUpdated', Order => 'DESC', Rows => 25, ); my $Collection = RT::Tickets->new( $session{'CurrentUser'} ); $Collection->FromSQL($Query); <%ARGS> $UserEmail