QuickTicket
You can quickly create a ticket using the QuickCreate-portlet (Homepage Component) on "RT-at-a-glance" home page. But you can neighter directly change the status of the new ticket nor add values to a custom field. Sometimes you just want to quickly create a ticket for documentation purpose. Because of that it would be helpfull to create it with status "resolved" and some values for custom fields.
Create new portlet
First create a new portlet that is called "QuickTicket":
Copy html/Elements/QuickCreate to local/html/Elements/QuickTicket
To use it on your homepage you have to change etc/RT_Config.pm. Look for $HomepageComponents and add "QuickTicket" to it; e.g.:
Set($HomepageComponents, [qw(QuickCreate QuickTicket Quicksearch MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards SavedSearches)]);
Now you can add your new portlet "QuickTicket" to your homepage but it is just a clone of QuickCreate.
Update portlet name and id
Find the line that says
<div class="quick-create">
and change it to
<div class="quick-ticket">
Find the line that says
and change the part that says "QuickCreate" and change it to "QuickTicket".
Add status to portlet
Adding a select-box for the ticket-status, which has resolved-status preselected:
<&|/l&>Status: <& /Elements/SelectStatus, Name=>"Status", Default => "resolved" &>
Add custom fields to portlet
To add the custom fields of the current selected queue is a bit more complicated, because the fields has to change if the user selects another queue. To prevent a new page load every time the user changes the queue you can load the fields in background using AJAX.
First you need a component that returns the custom fields for a queue. Create local/html/QuickTicketCustomFields.html with the following content:
<& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &> <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &> <%init> my $Queue = $ARGS{Queue}; my $QueueObj = RT::Queue->new($session{'CurrentUser'}); $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
Now add a new row to local/html/Elements/QuickTicket to display the custom fields
and some JavaScript to load the custom fields and display them: To save entered values for custom fields you have to change index.html. Copy html/index.html to local/html/index.html and add the following lines: if ( $ARGS{'QuickTicket'} ) { my $QueueObj = RT::Queue->new($session{'CurrentUser'}); $QueueObj->Load($ARGS{Queue}) or Abort(loc("Queue could not be loaded.")); my $CFs = $QueueObj->TicketCustomFields(); my $ValidCFs = $m->comp( '/Elements/ValidateCustomFields', CustomFields => $CFs, ARGSRef => \%ARGS ); if ( $ValidCFs && !$skip_create && $ARGS{'Subject'} && $ARGS{'Requestors'}) { my ($t, $msg) = CreateTicket( From => $session{'CurrentUser'}->EmailAddress, %ARGS,); push @results, $msg; %ARGS = undef; if ( $t && $t->Id && RT->Config->Get('DisplayTicketAfterQuickCreate', $session{'CurrentUser'}) ) { MaybeRedirectForResults( Actions => \@results, Path => '/Ticket/Display.html', Arguments => { id => $t->Id }, ); } } elsif (!($ARGS{'Subject'} && $ARGS{'Requestors'})) { push @results, loc("Please set subject and requestors"); } elsif (!$ValidCFs) { push @results, loc("Please set required custom fields"); } delete $ARGS{'QuickTicket'}; #otherwise there will be a redirect loop delete $ARGS{'QuickCreate'}; MaybeRedirectForResults( Actions => \@results, Path => '/', Arguments => \%ARGS, ); }
Show entered values again
If you want previously entered values to be visible again after submitting the form with invalid data,
change line 78 of /local/html/index.html to:
<& /Elements/MyRT, %ARGS &>
Copy /html/Elements/MyRT to local/html/Elements/MyRT and change line 95 and following lines to
my %newArgs = (%{ $entry->{arguments} || {} }, %ARGS); # XXX: security check etc. $m->comp( $name, %newArgs );
Because of that QuickTicket is called with the arguments and previously entered values can be shown again.