Hi All,
I’m trying to assign a Custom Field only when tickets are changed to Queue 5 or 8. If I set the Scrip stage to Normal, my code works and sets the CF but, the CF is set back to its original value at the end of transaction:
Ticket History:
#2020-01-19 05:46 root (Enoch Root) - Queue changed from Noc-QA-Close to Noc-1NewTickets
#2020-01-19 05:46 The RT System itself - T_Retriage 1 changed to 2
#2020-01-19 05:46 The RT System itself - Status changed from ‘open’ to ‘new’
#2020-01-19 05:46 root (Enoch Root) - T_Retriage 2 changed to 1
If I set the Scrip stage to Batch, it works only if I DO NOT change ticket Status at the same time; If I do set Status at the same time, my code fails because TransactionObj->OldValue and NewValue are not the queue IDs anymore (but the new/old statuses)…
I’m using RT 4.4.4.
Any suggestion?
Thank you!
My Action commit code:
my $self = shift;
my $queueold = $self->TransactionObj->OldValue;
my $queuenew = $self->TransactionObj->NewValue;
my $cfT_Retriage = $self->TicketObj->CustomFieldValuesAsString(“T_Retriage”);
$RT::Logger->debug( “>>>> TRANSACTION TYPE: “. $self->TransactionObj->Type .” <<<<\n” );
$RT::Logger->debug( “>>>> TRANSACTION FIELD: “. $self->TransactionObj->Field .” <<<<\n” );
$RT::Logger->debug( “>>>> TRANSACTION OLD VALUE: “. $queueold .” <<<<\n” );
$RT::Logger->debug( “>>>> TRANSACTION NEW VALUE: “. $queuenew .” <<<<\n” );
if (($queuenew eq 5) || ($queuenew eq 8)) {
$RT::Logger->debug( “>>>> TICKET QUEUE (new 5/8) <<<<\n” );
Inc T_Retriage
$RT::Logger->debug( “>>>> cf T_Retriage Old: “. $cfT_Retriage .” <<<<\n” );
if ($cfT_Retriage eq “”) {$cfT_Retriage = 0;}
$cfT_Retriage = $cfT_Retriage + 1;
$RT::Logger->debug( “>>>> cf T_Retriage New: “. $cfT_Retriage .” <<<<\n” );
my ($ret, $msg) = $self->TicketObj->AddCustomFieldValue(Field => ‘T_Retriage’, Value => $cfT_Retriage);
$RT::Logger->debug( “>>>> ret “. $ret .” with msg “. $msg .” <<<<\n” );
$cfT_Retriage = $self->TicketObj->CustomFieldValuesAsString(“T_Retriage”);
$RT::Logger->debug( “>>>> cf T_Retriage Now: “. $cfT_Retriage .” <<<<\n” );
}
return 1;
Debug logger (When Queue change goes with Status Change):
TRANSACTION TYPE: Status <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:28)
TRANSACTION FIELD: Status <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:29)
TRANSACTION OLD VALUE: open <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:31)
TRANSACTION NEW VALUE: new <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:32)
Debug logger (When Queue change goes alone):
TRANSACTION TYPE: Set <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:28)
TRANSACTION FIELD: Queue <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:29)
TRANSACTION OLD VALUE: 7 <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:31)
TRANSACTION NEW VALUE: 5 <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:32)
TICKET QUEUE (new 5/8) <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:58)
cf T_Retriage Old: 1 <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:60)
cf T_Retriage New: 2 <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:63)
ret 1296 with msg T_Retriage 1 changed to 2 <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:65)
cf T_Retriage Now: 2 <<<< (/opt/rt4/sbin/…/local/lib/RT/Action/SetCFsQChange.pm:67)
Initial data
@ScripActions = (
{ Name => ‘Set CFs Q Change’,
Description => ‘Set CFs Q Change’,
ExecModule => ‘SetCFsQChange’,
Argument => ‘’,
},
);
@Scrips = (
{ Queue => 0,
Description => ‘Set retriage CFs on Q Change’,
ScripCondition => ‘On Queue Change’,
ScripAction => ‘Set CFs Q Change’,
Template => ‘Blank’,
Stage => ‘TransactionBatch’,
},
);