Soft resolution of Request Tracker tickets.
We wanted to be able to close a ticket, without actually “closing” it. Thus the “pending” ticket status was born. We can set a ticket’s status as “pending”, and have it automatically
marked as “closed” n days later, if there haven’t been any replies in that time.
I have received permission from my employer to release this under the GNU GPLv2.
Now that the background info is done with, here’s the solution I came up with to be able to have a soft resolution of tickets.
First up: Add the status itself to the list of inactive statuses, since supposedly the ticket is done with, or the requester just doesn’t care enough anymore to be bothered with replying to it.
Put the following in etc/RT_SiteConfig.pm:
@InactiveStatus = qw(resolved rejected pending deleted) unless @InactiveStatus;
You’ll then need to create local/lib/RT/Action/AutoResolve.pm[1] with the following content:
package RT::Action::AutoResolve; require RT::Action::Generic; use strict; use vars qw/@ISA/; @ISA=qw(RT::Action::Generic); sub Describe { my $self = shift; return (ref $self ); } sub Prepare { my $self = shift; # if the ticket is already resolved don't re-resolve it. if ( ( $self->TicketObj->Status eq 'resolved' ) ) { return undef; } else { return (1); } } sub Commit { my $self = shift; $self->TicketObj->SetStatus( 'resolved' ); return (1); } 1;
This will be used as the --action argument to rt-crontool.
Create local/lib/RT/Condition/UntouchedInDays.pm[2] for the --condition used with rt-crontool:
package RT::Condition::UntouchedInDays; require RT::Condition::Generic; use RT::Date; @ISA = qw(RT::Condition::Generic); use strict; use vars qw/@ISA/; sub IsApplicable { my $self = shift; if ((time()-$self->TicketObj->LastUpdatedObj->Unix)/3600/24 >= $self->Argument) { return 1 } else { return 0; } } 1;
local/lib/RT/Search/PendingTicketsInQueue.pm will be used for the --search.[3]
package RT::Search::PendingTicketsInQueue; use strict; use base qw(RT::Search::Generic); sub Describe { my $self = shift; return ($self->loc("No description for [_1]", ref $self)); } sub Prepare { my $self = shift; $self->TicketsObj->LimitQueue(VALUE => $self->Argument); $self->TicketsObj->LimitStatus(VALUE => 'pending'); return(1); } 1;
Now that the pre-requisites are in place, we can create the rt-pending script that should be called daily to resolve tickets that have been set as pending for n days (in this example: n = 7).[4]
#! /bin/sh /opt/rt3/bin/rt-crontool --search RT::Search::PendingTicketsInQueue --search-arg 'Help Desk' --condition RT::Condition::UntouchedInDays --condition-arg 7 --action RT::Action::AutoResolve
That finishes up the portion to mark the tickets as resolved, after the given number of days have passed, with no updates to a ticket. Next up is re-opening the ticket if someone replies to it.
- I’d love to give credit on where I found the code that this is based on, but I can’t seem to find it on the RT Wiki anymore. If you can find the original, let me know so I can give proper credit for this. [↩]
- Modified from UntouchedInHours. [↩]
- I can’t seem to find where I got this code from originally. If you recognize it, or are the original author, please let me know. [↩]
- I just dropped this script into
/etc/cron.daily/, but I’m using Debian. You should adjust as appropriate for your distribution. [↩]
Pages: 1 2




