OnResolveOnce
Contributed by Russell Mosemann.
Overview
A user might respond to a resolved ticket, perhaps just to say, "Thanks." That opens the ticket, and when it is marked resolved, again, the user receives another autonotification that the ticket has been resolved.
The scrip condition below matches when a ticket is resolved but only if the ticket has not been resolved before. That permits a user to receive an autonotification when the ticket is first resolved, but if the ticket is opened and resolved, again, no autonotification is sent. Tickets merged into this ticket are ignored, in case they were resolved in the past.
Installing
1. Go to Configuration->Global->Scrips
2. Click on (no name) above "On Resolve Notify Requestors with template Resolved"
3. Give the scrip a name, such as "OnResolveOnce"
4. Change Condition to "User Defined"
5. Copy the code below into the Custom condition box
6. Click Create
Scrip Code
# OnResolveOnce # 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);