[rt-users] trouble setting custom field from scrips

Borut Mrak b at aufbix.org
Tue Apr 3 04:36:12 EDT 2007


I'm having a little trouble setting a custom field from a scrip.

What I'm trying to do is add some kind of notification so web interface
users see which of their tickets has unanswered customer responses.

What I have now is:

Description: WaitingFieldOnTransaction
Condition: OnTransaction
Action: User Defined
Template: Global Template: blank
Stage: Transaction Create
Custom action preparation code:

f ($trans->Type == "Comment" || $trans->Type == "Correspond") {
  return 1;
} else {
  return 0;

Custom action cleanup code:
my $ownerid=$self->TicketObj->Owner;
my $actorid=$self->TransactionObj->Creator;

my $cf = RT::CustomField->new( $RT::SystemUser );
$cf->LoadByName( Name => 'WaitingForOwner' );

if($ownerid eq $actorid) {
  $self->TicketObj->AddCustomFieldValue(Field => $cf, Value => 'answered');
} else {
  $self->TicketObj->AddCustomFieldValue(Field => $cf, Value => 'Waiting');

What happens is that in case the requestor responds, the custom field
gets set to 'Waiting', but right after that it falls back to 'answered':

Mon Apr 02 08:29:42 2007  	 RT_System - WaitingForOwner answered changed
to Waiting  	 	
Mon Apr 02 08:29:42 2007 	RT_System - WaitingForOwner Waiting changed to

What could cause this? I also have a scrip that sets the status to
Waiting, but that only runs OnCreate.

thanks for any thoughts,
Borut Mrak.

More information about the rt-users mailing list