[rt-users] OnResolve Once scrip condition

Russell Mosemann mose at ns.cune.edu
Sun Mar 6 10:47:42 EST 2005


I have written a scrip condition for the "On Resolve" autonotify scrip
that will only match if the current ticket has not been resolved before.  
This permits a notification on the first resolved event but avoids
notification on subsequent open/resolved events (e.g., when the requestor
keeps replying to a resolved ticket :-).  If transactions from another
ticket have been merged into the current ticket, they are ignored in case
the other ticket was resolved in the past.

To use the scrip condition, go to Configuration->Global->Scrips and click
on (no name) above "On Resolve Notify Requestors with template Resolved".

1. Give the scrip a name, such as "OnResolve Once"
2. Change Condition to "User Defined"
3. Copy the code below into the Custom condition box
4. Click Create

This has been tested on 3.4.1.  As always, use at your own risk.

----
Russell Mosemann, Ph.D. * Computing Services * Concordia University, Nebraska
"Milk of Magnesia is not a dairy product."


# OnResolve Once
# This scrip condition matches only if the current transaction is
# "resolved" and the current ticket has no other resolved transactions.
#
# First, check if the current transaction is "resolved".  If so, get
# the list of transactions associated with the current ticket and go
# through them one by one.  If the ticket number in the transaction
# matches the current ticket (i.e., this isn't a transaction from a
# merged ticket) and the transaction is "resolved", count it.  When
# we are all done, return true if we only found 1 resolved transaction
# (i.e., the current one) and false otherwise.

my $result = undef;

if ($self->TransactionObj->Type eq "Status" &&
    $self->TransactionObj->NewValue eq "resolved")
{
    my $trans_list = $self->TicketObj->Transactions;
    my $trans;
    my $num_resolved = 0;

    while ($trans = $trans_list->Next)
    {
        $num_resolved++ if ($trans->Ticket == $self->TicketObj->Id) &&
                           ($trans->Type eq "Status") &&
                           ($trans->NewValue eq "resolved");
    }
    $result = ($num_resolved <= 1);
}

return($result);




More information about the rt-users mailing list