Result page not up to date after TransactionBatch scrips

Hello,

We use RT 4.0.13, We customized our installation by some scrips. Part of
them have to work in TransactionBatch mode.
One of the scrips changes the ticket owner on queue change. This is done by
scrip working in mentioned TransactionBatch mode.

When the queue is changed on Basics screen (Ticket/Modify.html), scrip is
executed without a failure.
The problem is that result page shows the OLD VALUE of the owner.
Clicking Display or Basics again shows that owner was really changed by the
scrip.

The problem exists on blank RT instance as well (only one new queue and
following scrip created).

1;
0
User Defined
User Defined
TransactionBatch
Blank

my ($status_id, $status_msg);
my $qId;
my @batch = @{ $self->TicketObj->TransactionBatch };

  foreach my $trans ( @batch ) {

      if ($trans->Type eq 'Set' && $trans->Field eq 'Queue') {
       #if queue changed to COE_XX set owner to opcenter
        $qId = $trans->NewValue;
        my $qObj = new RT::Queue($RT::SystemUser);
        $qObj->Load($qId);
        if ($qObj->Name eq 'COE_XX')
        {
          ($status_id, $status_msg) = $self->TicketObj->SetOwner
  ('opcenter', 'Force');
          $RT::Logger->info("Change owner: $status_msg");
          return !$status_id;
        }

      #in other cases, just set owner to nobody
      ($status_id, $status_msg) = $self->TicketObj->SetOwner(RT::Nobody
  (), 'Force');
      $RT::Logger->info("Change owner: $status_msg");
      return 1;
      }

  }
  1;
my @batch = @{ $self->TicketObj->TransactionBatch }; foreach my $trans ( @batch ) { return 1 if ($trans->Field eq "Queue"); } return 0;

Do you have any idea, how to force RT to show current values on result
page ?

Best regards,
Rafal

We use RT 4.0.13, We customized our installation by some scrips. Part of
them have to work in TransactionBatch mode.
One of the scrips changes the ticket owner on queue change. This is done by
scrip working in mentioned TransactionBatch mode.

When the queue is changed on Basics screen (Ticket/Modify.html), scrip is
executed without a failure.
The problem is that result page shows the OLD VALUE of the owner.
Clicking Display or Basics again shows that owner was really changed by the
scrip.

I’m not surprised. In order to avoid problems with TransactionBatch
scrips, the ticket is cloned and worked on. The ticket object in the
page is not directly acted on by the Scrip.

TransactionBatch scrips through the 3.6/3.8/4.0 series have been
inconsistent about when it updates. I don’t think there’s ever been a
guarantee that it will update the object and TransactionBatch scrips
in general are too magical.

Do you have any idea, how to force RT to show current values on result
page ?

Use one of the other callbacks in that page to reload the ticket
object, $TicketObj->Load($TicketObj->Id); from the BeforeActionList
callback or one of the others should be enough.

-kevin

Hi Kevin,

Thank you for your advice.
Works perfectly.

RafalFrom: Kevin Falcone falcone@bestpractical.com
To: rt-users@lists.bestpractical.com
Date: 2013-09-10 04:12
Subject: Re: [rt-users] Result page not up to date after
TransactionBatch scrips
Sent by: rt-users-bounces@lists.bestpractical.com

We use RT 4.0.13, We customized our installation by some scrips. Part of
them have to work in TransactionBatch mode.
One of the scrips changes the ticket owner on queue change. This is done
by
scrip working in mentioned TransactionBatch mode.

When the queue is changed on Basics screen (Ticket/Modify.html), scrip is
executed without a failure.
The problem is that result page shows the OLD VALUE of the owner.
Clicking Display or Basics again shows that owner was really changed by
the
scrip.

I’m not surprised. In order to avoid problems with TransactionBatch
scrips, the ticket is cloned and worked on. The ticket object in the
page is not directly acted on by the Scrip.

TransactionBatch scrips through the 3.6/3.8/4.0 series have been
inconsistent about when it updates. I don’t think there’s ever been a
guarantee that it will update the object and TransactionBatch scrips
in general are too magical.

Do you have any idea, how to force RT to show current values on result
page ?

Use one of the other callbacks in that page to reload the ticket
object, $TicketObj->Load($TicketObj->Id); from the BeforeActionList
callback or one of the others should be enough.

-kevin