Hi Doro,

I had a similar issue and I never quite figured out why it was happening. I was able to eventually trick the system into letting me make the change stick.

My scrip was triggered when a user resolved a ticket via the web gui. The scrip changed the ticket owner to the current user if it was Nobody and then triggered some other stuff. Although the ownership change showed up in the transactions table and was logged in the logs, the ticket ended up with the original owner (Nobody). What I finally did was to create another scrip to undo the undo that RT was doing. It triggered if the owner got changed to a system user and the status was resolved. When triggered, it just changed the owner back to the transaction's oldvalue and everything ended up as it should. I have some guesses as to why RT flipped the owner back to Nobody, but they're mostly conjecture or conspiracy theory. You should be able to modify my scrip to undo the unwanted reversion of your CF.

Here's the scrip I use to redo what RT undid.

Condition:
{ ### True if resolved and ticket 'given' to system acct <= 12
  my $MyName = "Scrip DNS:45:Condition (Revert Owner)";
  my $Transaction = $self->TransactionObj;
  my $Ticket = $self->TicketObj;
  my $highest_system_user = 12;
  my $val = $Transaction->Type eq 'Give'
         && $Transaction->Field eq 'Owner'
         && $Transaction->NewValue <= $highest_system_user
         && $Ticket->Status eq 'resolved';
$RT::Logger->debug("$MyName (" . $Transaction->Id . ") condition is " . ($val ? "True" : "False"));
  return $val;
}

Prep code:
return 1;

Cleanup code:
### Undo RT's meddling change, set owner back to original
my $MyName = "Scrip DNS:45:Cleanup (Revert Owner)";
my $Transaction = $self->TransactionObj;
my $Ticket = $self->TicketObj;
my $oldowner = $Transaction->OldValue;
$Ticket->_Set(Field=>'Owner', Value=>$oldowner, RecordTransaction=>0);

My best guess is that after all of your transactions run, RT looks at the values that were passed from the web form and compares them to the ticket values and then makes whatever changes are needed. But this doesn't seem to hold up under all conditions, so who knows?

Regards,
Gene

At 09:21 AM 11/6/2007, Dorothea Muecke-Herzberg wrote:
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


--
Gene LeDuc, GSEC
Security Analyst
San Diego State University
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we'll take
up to 20 percent off the price. This sale won't last long, so get in touch today. Email us at [EMAIL PROTECTED] or call us at +1 617 812 0745.


Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com

Reply via email to