Trouble setting custom field from scrips

Hello,

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
answered

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.

Borut Mrak wrote:

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’:

My bad, it’s the other way around. We display newest transactions first.
The CF gets set to answered, and then right back to Waiting.

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 answered

regards,
Borut Mrak.

Might there be another scrip that is firing right after the one you
described? I was experiencing that sort of behavior in a workflow chain
until I disabled all of the global scrips. I’ve found that rt.log (logging
at debug level) and my apache logs give a lot of useful information when I
can’t figure out what is going on. In fact, when I’m working on new scrips
or templates, I usually have “tail -f rt.log” and “tail -f
www/logs/error.log” running in separate windows so I can watch what happens
as the scrips and templates run (or don’t).

At 02:42 AM 4/3/2007, Borut Mrak wrote:

Borut Mrak wrote:

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’:

My bad, it’s the other way around. We display newest transactions first.
The CF gets set to answered, and then right back to Waiting.

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 answered

Gene LeDuc, GSEC
Security Analyst
San Diego State University