[rt-users] Resetting due date when moving tickets between queues

Joel Dahl joel at vnode.se
Tue Jun 5 04:22:06 EDT 2012


I have setup 3 queues in RT 4.0.6, each queue with different default values
for automatically setting a due date when a new ticket is created:

Queue "High" - requests should be due in 1 day
Queue "Normal" - requests should be due in 7 days
Queue "Low" - requests should be due in 14 days

So for example, when I create a ticket in the normal queue, RT automatically
sets the due date to 7 days from now.

The problem is of course moving tickets between queues, because the due date
won't automactially update depending on the queue so I'm forced to manually
change the due date each time I move a ticket between queues. 

I found a small scrip on the wiki that almost does what I want. I have
slightly modified it for my purpose and it almost works. I want the scrip to
adjust the due date based on the created date. When moving a ticket between
queues, the due date should be set to 7 days from the creation date if
placed in the normal queue, for example.

With the scrip below, X days are added based on today date, instead of X days
based on the creation date.

I'd appreciate some help with this. :-)

Description: On Queue Change Set Priority and DueDate
Condition: On Queue Change
Action: User Defined
Template: Global template: Blank
Stage: TransactionBatch

Custom condition: #blank

Custom action preparation code: return 1;

Custom action cleanup code:

my $queue_id = $self->TransactionObj->NewValue;
my $queue = RT::Queue->new( $RT::SystemUser );
$queue->Load( $queue_id ); 

my $due_date = RT::Date->new( $RT::SystemUser );
$due_date->Set( Format => 'ISO', Value => $self->TicketObj->Due );

if ( $queue->DefaultDueIn == 0 ) {
  $due_date->Set( Format => 'ISO', Value => 0 );
} else {
  $due_date->AddDays( $queue->DefaultDueIn );

$RT::Logger->info("On Queue Change set ticket #". $self->TicketObj->id ." due date to ". $due_date->ISO );
my ( $status, $msg ) = $self->TicketObj->SetDue( $due_date->ISO );
unless ( $status ) {
  $RT::Logger->error( "Unable to assign due date to ". $due_date->ISO );
return 1;


More information about the rt-users mailing list