首页 > 解决方案 > I want to check the previous status within an RT scrip?

问题描述

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.

标签: rt

解决方案


您不能在 TicketObj 上调用 OldValue,它是一个 Transaction 方法。因此,如果我正确理解了您的需求,您需要编写一个脚本,触发 StatusChange && Correspondence 设置状态。这有点棘手。

AFAIK,您需要创建一个在 Correspondence 上触发的批处理脚本,然后找到 StatusChange 的最后一个事务并将其还原。像这样的东西可以工作:

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);

推荐阅读