Conditional Reopen Reject

From Request Tracker Wiki
Jump to navigation Jump to search

Introduction

Conditional Reopen Reject lets you decide that, after a set amount of time since resolution, users won't be able to reopen a ticket.

It works with two scrips and a template, as explained below.

Keep in mind that this is configured so that tickets become non-reopenable after a week since resolution. If you want a different timeframe, just change the $Days variable.


The default reopen script

There's a default script for opening inactive tickets unconditionally. It's called On Correspond Open Inactive Tickets. You have to disable it first (or you may choose to repurpose it for one of the scripts below.


Setting up the scrip for reopening recent tickets

Description: On Correspond ( < week ) Open Inactive Tickets

Condition: User defined

Action: Open Inactive Tickets

Template: Blank

Applies to: Global

Custom condition:

# This condition is true only for mails coming in within a week of the ticket being closed.
# Script "On Correspond  ( > week ) Open Inactive Tickets" is strongly related.

# my $Days = 60; # debugging
my $Days = 60*60*24*7; # 7 days

my $TransactionObj = $self->TransactionObj;
my $TicketObj = $self->TicketObj;
my $QueueObj = $TicketObj->QueueObj;
 
return 0 unless $TransactionObj->Type eq 'Correspond';
 

if ( $TransactionObj->IsInbound && 
    $QueueObj->IsInactiveStatus( $TicketObj->Status ) &&
    time() - $TicketObj->ResolvedObj->Unix < $Days ) {
 
  return 1; # reopen the ticket
}

return 0;  # Don't reopen the ticket. Another script should send the user a mail that the ticket cannot be reopened.

Custom action preparation code: empty

Custom action commit code: empty


Setting up the scrip for rejecting reopening of old tickets

Description: On Correspond ( > week ) Open Inactive Tickets

Condition: User defined

Action: Autoreply To Requestors

Template: Conditional Reopen Reject

Applies to: Global

Custom condition:

# Inspired by this: https://rt-wiki.bestpractical.com/wiki/Conditional_Reopen_Reject
# This condition is true only for mails coming in after the ticket has been closed for a week.
# Script "On Correspond ( < week ) Open Inactive Tickets" is strongly related to this.

# my $Days = 60; # debugging
my $Days = 60*60*24*7; # 7 days

my $TransactionObj = $self->TransactionObj;
my $TicketObj = $self->TicketObj;
my $QueueObj = $TicketObj->QueueObj;
 
return 0 unless $TransactionObj->Type eq 'Correspond';
 

if ( $TransactionObj->IsInbound && 
    $QueueObj->IsInactiveStatus( $TicketObj->Status ) &&
    time() - $TicketObj->ResolvedObj->Unix > $Days ) {
 
  return 1;  # Send a mail saying that this ticket cannot be reopened.
}

return 0; # Don't send the mail, another script may reopen the ticket.

Custom action preparation code: empty

Custom action commit code: empty


Setting up the template

This is how the template should be configured:

Name: Conditional Reopen Reject

Description: Reject reopen if ticket has been closed for more than X days

Type: Perl

Content:

Subject: WARNING - TICKET REJECTED: {$Ticket->Subject}

Ticket #{$Ticket->id()} has been closed for more than 7 days: it is not possible to reopen it.

Please submit a new ticket instead.


Thank you,
{$Ticket->QueueObj->CorrespondAddress()}