Technosorcery Networks

The professional exploits of Jacob Helwig

Thursday, September 6, 2007

Soft resolution of Request Tracker tickets.

Now we’ll create the pre-requisites necessary to setup the queue, and global scrips relating to pending tickets.
local/lib/RT/Condition/ReplyToPending.pm[1]

package RT::Condition::ReplyToPending;
use strict;
use base qw(RT::Condition::Generic);
sub IsApplicable {
   my $self = shift;
   my $ticket = $self->TicketObj;
   my $transaction = $self->TransactionObj;
   if ( $transaction->Type eq 'Correspond' &&
       $ticket->Status eq 'pending' &&
       $transaction->Creator != 1 )  { # prevent loop
       return(1);
   }
   else {
       return(undef);
   }
}
1;

You can use the following template[2] to make the conditions, and actions described here available through the web scrip interface:

#!/usr/bin/perl
use strict;
use Unicode::String qw(utf8 latin1);
# Replace this with your RT_LIB_PATH
use lib "/opt/rt3/lib";
# Replace this with your RT_ETC_PATH
use lib "/opt/rt3/etc";
use RT;
use RT::Interface::CLI qw( CleanEnv GetCurrentUser );
use RT::ScripCondition;
CleanEnv();
RT::LoadConfig();
RT::Init();
##Drop setgid permissions
RT::DropSetGIDPermissions();
##Get the current user all loaded
our $CurrentUser = GetCurrentUser();
unless( $CurrentUser->Id )
{
  print "No RT user found. Please consult your RT administrator.\n";
  exit 1;
}
my $sc = new RT::ScripCondition($CurrentUser);
 
$sc->Create(
           Name                 => 'On Reply to Pending',
           Description          => "Reply to a ticket marked as pending.",
           ExecModule           => 'ReplyToPendingTicket',
           ApplicableTransTypes => 'Any'
           );

Now that these steps are done, you can create a global scrip with the condition set to On Reply to Pending, and the action set to Open Ticket. This will re-open any tickets as soon as someone replies to them, but not if anyone comments on them. (Commenting will, however delay the resolution of a ticket.)

You’ll then need to create either a global scrip, or a queue specific scrip for each queue where you want people to be able to reply to a pending ticket, and have it re-opened. (Personally I recommend the global scrip method.)

This step requires direct DB access. You’ll need to be able to do an insert on the ScripConditions table. <user_id> should be replaced with a valid user ID, taken from one of the other entries in the ScripConditions table.

INSERT INTO ScripConditions(
  Name,
  Description,
  ExecModule,
  Argument,
  ApplicableTransTypes,
  Creator,
  Created,
  LastUpdatedBy,
  LastUpdated
) VALUES (
  'On Pending',
  'Whenever a ticket is marked as pending resolution',
  'StatusChange',
  'pending',
  'Status',
  <user_id>,
  NOW(),
  <user_id>,
  NOW()
);

This sets up the “On Pending” scrip condition, so that you’ll be able to create a scrip such as “On Pending Reply to Requesters with template XXXXXX”, and have a custom message sent out to inform the requester that the ticket will close itself in n days, unless they reply to it.

  1. Heavily based on ReplyToResolved.pm []
  2. Also taken from the ReplyToResolved RT Wiki site. []
posted by Jacob at 12:51 pm

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Powered by WordPress