I want to check the previous status within an RT scrip?

312 views Asked by At

my $TransactionPreviousStatus = $self->TicketObj->Status->OldValue:

I am thinking this should give the old status but I end up getting the current status

For Ex:

Old status: open

Current Status: reply-pls

So when somebody will reply on the ticket, a custom script will execute which should change the status to old value (i.e., open) but again it goes back to reply-pls.

1

There are 1 answers

1
Houmles On

You can not call OldValue on TicketObj, it's a Transaction method. So if I understand your needs correctly, you need to write a scrip which triggers on StatusChange && Correspondence which sets the status back. This is little bit tricky.

AFAIK you need to create a batch scrip which triggers on Correspondence and then find the last transaction of StatusChange and revert it back. Something like this could work:

Description: On correspond don't change the status
Condition: On Correspond
Action: User defined
Template: Blank
Stage: Batch
Custom action commit code:

my $transactions = $self->TicketObj->Transactions;
my $last_status;
while (my $transaction = $transactions->Next) {
  if ($transaction->Type eq "Status" ) {
    $last_status = $transaction;
  }
}
$self->TicketObj->SetStatus($last_status->OldValue);