ReplyToResolved: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
(No difference)

Revision as of 15:36, 6 April 2016

HomePage > Contributions > ReplyToResolved

ReplyToResolved

Introduction

this is a simple scrip to catch correspondence/reply to ticket marked 'resolved'

the scrip condition

Save this file as e.g. /usr/local/share/request-tracker3.6/lib/RT/Condition/ReplyToResolvedTicket.pm

package RT::Condition::ReplyToResolvedTicket;
use strict;
use base qw(RT::Condition::Generic); # thanks Ruslan for the suggestion
sub IsApplicable {
   my $self = shift;
   my $ticket = $self->TicketObj;
   my $transaction = $self->TransactionObj;
   if ((($transaction->Type eq 'Correspond') || ($transaction->Type eq 'Comment'))  &&
       $ticket->Status eq 'resolved' &&
       $transaction->Creator != 1)  { # prevent loop
       return(1);
   }
   else {
       return(undef);
   }
}
eval "require RT::Condition::ReplyToResolvedTicket_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/ReplyToResolved_Vendor.pm});
eval "require RT::Condition::ReplyToResolved_Local";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/ReplyToResolved_Local.pm});
1;

installation

The following Perl script is used to register i.e. active the above code in RT and is no longer necessary afterwards:

#!/home/rt/perl/bin/perl
 use strict;
 use Unicode::String qw(utf8 latin1);
 # Replace this with your RT_LIB_PATH
 use lib "/home/rt/rt/lib";
 # Replace this with your RT_ETC_PATH
 use lib "/home/rt/rt/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 Resolved Ticket',
            Description          => "Lors d'une r�ponse � un ticket r�solu",
            ExecModule           => 'ReplyToResolvedTicket',
            ApplicableTransTypes => 'Any'
            );
 

problems

If you face problems with this scrip take a look at the NotResolved condition scrip as is it very similar, and I have detailled it more.

conclusion

I personally use it with the ForkIntoNewTicket scrip action in order to open a new ticket on reply to resolved ticket. I also have disabled the global scrip On Reply Open by setting "Stage:" to "disabled". For the new script use the following values:

Description: 	Replies to resolved tickets create a new ticket.
Condition: 	On Reply To Resolved Ticket
Action: 	Force Correspondence into new Ticket
Template: 	Global Template: Correspondence
Stage: 	TransactionCreate