Order of actions on ticket

Hello there,

when I add comment or corespondence to ticket AND change the owner, the message
is recorded first and then the owner changed. This is problem. I have a scrip
that sends any new entry to owner so I need the owner change to come first.
Now I first have to change owner in ticket properties and then add the message.

Could anyone help with this? I was unable to find solution in ML or hack it myself.

Thanks.

Ing. Tomďż˝ Valenta
Tel: 777 210 635
www.Trustica.cz

  • On 23/12/06 18:40 +0100, Ing. Tomas Valenta wrote:
    |
    | Hello there,
    |
    | when I add comment or corespondence to ticket AND change the owner, the message
    | is recorded first and then the owner changed. This is problem. I have a scrip
    | that sends any new entry to owner so I need the owner change to come first.
    | Now I first have to change owner in ticket properties and then add the message.
    |
    | Could anyone help with this? I was unable to find solution in ML or hack it myself.

Why do you think RT should be able to read your mind? It follows the
order of events, but cannot contemplate that order.

    cheers
   - wash 

Odhiambo Washington . WANANCHI ONLINE LTD (Nairobi, KE) |
wash () WANANCHI ! com . 1ere Etage, Loita Hse, Loita St., |
GSM: (+254) 722 743 223 . # 10286, 00100 NAIROBI |
GSM: (+254) 733 744 121 . (+254) 020 313 985 - 9 |
“Oh My God! They killed init! You Bastards!”
–from a /. post

Odhiambo Washington wrote:

Why do you think RT should be able to read your mind? It follows the
order of events, but cannot contemplate that order.

That is a very eloquent way to put it :slight_smile:

In response to the original poster, you could experiment with
TransactionBatch mode and your “On Correspond” and “On Comment” scrips
so that the notification to the owner is posted after the owner change,
rather than before.

Also, according to the BP Wiki (but not tested by me), scrips are
executed in alphanumeric order according to the description. This was a
huge surprise to me when I read it a couple of days ago :slight_smile: So you might
be able to order the scrips by putting numbers in front of them or
something.

Rick R.

Also, according to the BP Wiki (but not tested by me), scrips are
executed in alphanumeric order according to the description.
This was a
huge surprise to me when I read it a couple of days ago :slight_smile:
So you might
be able to order the scrips by putting numbers in front of them or
something.

From what I can tell, this is purely rumor. At least, before 3.6.x - I
haven’t looked at that code yet. But certainly not true for 3.4.x or
3.5.x. The Prepare subroutine in lib/RT/Scrips_Overlay.pm calls
_FindScrips(), which simply gets all of the scrips from the database in
the order in which the database returns them to you. Whatever you get
from doing a straight query against the backend, you’ll get in RT. They
aren’t even ordered by Scrip.id, which I had hoped for.

However, I have modified the Prepare subroutine in
lib/RT/Scrips_Overlay.pm to do just that - ordering by Description. It
was actually a fairly trivial change. Here’s a patch against the 3.4.3
tree, if I am not mistaken (else, it’s 3.4.1 - my production code is
based on that version with selected changes from later versions).

begin patch -------------------------

@@ -220,9 +220,15 @@

 $self->_FindScrips( Stage => $args{'Stage'}, Type => $args{'Type'}

);

  • my %sorted_scrips = ();

  • while (my $scrip = $self->Next()) {

  •   $sorted_scrips{ $scrip->Description() } = $scrip;
    
  • }

    #Iterate through each script and check it’s applicability.

  • while ( my $scrip = $self->Next() ) {
  • foreach my $scripid (sort keys %sorted_scrips) {
  •   my $scrip = $sorted_scrips{$scripid};
    
       next
         unless ( $scrip->IsApplicable(
    

end patch ---------------------------

In other words, all I did was use a hash to sort the scrips as I stepped
through each one with a while loop, then replaced the while loop with a
foreach. I had thought about doing a numeric sort (with {$a <=> $b}),
but I figure people can put zeroes in front of their numbers for
sorting. Enjoy!

Eric Schultz
United Online