[rt-users] custom field resets to previous value after scrip runs
Dorothea Muecke-Herzberg
dmh at ngat.com
Tue Nov 6 12:21:25 EST 2007
Hi,
I've got some strange behaviour here. I have a scrip that changes the
value of custom field
ReleasePhase to "07_Signoff" and the ticket status to "resovled" when
a different custom field is
set to "completed".
Strangely, after the changes have gone through (and can be traced in
the ticket history),
in the last transaction the custom field "ReleasePhase" gets changed
back to "05_Implementing":
# Tue Nov 06 17:16:01 2007 dmueckeherzberg - ReleasePhase
07_SignOff changed to 05_Implementing
# Tue Nov 06 17:16:01 2007 RT_System - Outgoing email recorded [Show]
# Tue Nov 06 17:15:59 2007 RT_System - Outgoing email recorded [Show]
# Tue Nov 06 17:15:59 2007 RT_System - Status changed from 'open'
to 'resolved'
# Tue Nov 06 17:15:58 2007 RT_System - ReleasePhase
05_Implementing changed to 07_SignOff
# Tue Nov 06 17:15:58 2007 dmueckeherzberg - RolloutOnFTN Completed added
Here is my scrip:
custom condition:
#only act if subject has "RolloutFT." and new custom field value is "Complete"
#
my $CFvalue = 'Completed';
unless ($self->TicketObj->Subject =~ /^RolloutFT.:/i) {return 0;}
unless ($self->TransactionObj->Type eq "CustomField" ) {return 0;}
unless ($self->TransactionObj->NewValue eq $CFvalue ) {return 0;}
return 1;
custom prep code:
return 1;
custom cleanup code:
my $CFName = 'ReleasePhase';
my $EndValue = '07_SignOff';
my $RecTransaction = 1;
### setting custom field $CFName to $EndValue
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
$CFObj->LoadByNameAndQueue( Name => $CFName, Queue => $QueueObj->id );
unless( $CFObj->id ) {
$CFObj->LoadByNameAndQueue( Name => $CFName, Queue => 0 );
unless( $CFObj->id ) {
$RT::Logger->warning("custom field '$CFName' isn't global or
defined for queue '". $QueueObj->Name ."'");
return undef;
}
}
{
my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue(
Field => $CFObj->id,
Value => $EndValue,
RecordTransaction =>
$RecTransaction );
unless( $st ) {
$RT::Logger->warning( "Couldn't set $EndValue as value for CF
$CFName:". $msg );
return undef;
}
}
return 1;
Any ideas what is going on?
Thank you
Doro
More information about the rt-users
mailing list