Scrip action triggers before ownership change

Hello,

I want to set up a scrip to help those who forget to take a ticket before they reply.

The condition of the scrip is “On Correspond”. I copied the action code from here:
https://rt-wiki.bestpractical.com/wiki/AutoSetOwner

The action works fine however the condition seems to trigger too early. If I send a reply to a ticket without changing the owner on the update page it executes as follows.

  1. Sends my reply email.
  2. Triggers scrip to set the owner to the current user.
  3. Then it performs the “Ticket and Transaction” section which sets the owner back to “Nobody”.

Is there an easy way of getting around this or simply automatically setting the owner if someone replies to a new ticket?

Any help would be much appreciated.

If this is a non-global scrip, have you tried altering the position of this scrip in the queue’s list of scrips? If you log in as an admin user, select the queue and then click on the Scrips tab in the menu bar, you’ll get a list of scrips attached to that queue. On the right hand side of non-global scrips you’ll see [Up]/[Down] - click on those to move that scrip up or down in the list. I’m guess you want your scrip to run last maybe?

You can do something similar with global scrips at Admin > Global > Scrips.

Thanks for the advice however the scrip was last in the priority. I have figured out what was causing the issue, its the Update.html page in RTIR. I didn’t realise they were separate update pages between extensions, sorry for not mentioning it.

In Update.html from the RTIR extension it looks like someone wanted the ability to set the default owner to the currently logged in user however the way the arguments work it always sets it to the ticket owner.

        {   name => 'Owner',
            comp => '/Elements/SelectOwner',
            args => {
                Name         => "Owner",
                TicketObj    => $Ticket,
                QueueObj     => $Ticket->QueueObj,
-                Default      => $ARGS{'Owner'} || $Ticket->Owner
-                    || $session{'CurrentUser'}->id,
+                Default      => $ARGS{'Owner'},
            }
        },

The argument Owner is not normally set on reply however if it is then the execution order seems to be as I mentioned above with the reply email being sent as a separate transaction before the owner update. If Owner is not set on reply you will see on the dropdown list Nobody in particular (Unchanged) which does not trigger the owner update transaction.