Hi everyone,

I'm setting a status of approvlreq for tickets that need approval.
Everything is working fine, except that once approved, the ticket's
status doesn't change! I would expect this scrip in the ___Approval
queue should be doing the job, right?

- When a ticket has been approved by all approvers, add correspondence to the 
original ticket
- On Resolve User Defined with template All Approvals Passed

---BEGIN---
# Find all the tickets that depend on this (that this is approving)

my $Ticket = $self->TicketObj;
my @TOP    = $Ticket->AllDependedOnBy( Type => 'ticket' );
my $links  = $Ticket->DependedOnBy;
my $passed = 0;

while (my $link = $links->Next) {
    my $obj = $link->BaseObj;
    next if ($obj->HasUnresolvedDependencies( Type => 'approval' ));
    if ($obj->Type eq 'ticket') {
        $obj->Comment( Content => $self->loc("Your request has been 
approved."), );
        $T::Approval  = $Ticket;    # so we can access it inside templates
        $self->{TicketObj} = $obj;  # we want the original id in the token line
        $passed = 1;
    } elsif ($obj->Type eq 'approval') {
        $obj->SetStatus( Status => 'open', Force => 1, );
    } elsif ($RT::UseCodeTickets and $obj->Type eq 'code') {
        my $code = $obj->Transactions->First->Content;
        my $rv;
        foreach my $TOP (@TOP) {
            local $@;
            $rv++ if eval $code;
            $RT::Logger->error("Cannot eval code: $@") if $@;
        }
        if ($rv or [EMAIL PROTECTED]) {
            $obj->SetStatus( Status => 'resolved', Force => 1, );
        } else {
            $obj->SetStatus( Status => 'rejected', Force => 1, );
        }
    }
}

# Now magically turn myself into a Requestor Notify object...
require RT::Action::Notify; bless($self, 'RT::Action::Notify');
$self->{Argument} = 'Requestor'; $self->Prepare;

return 0; # ignore $passed;
---END---

The comment gets added, but the status is never set to 'open'... Should
I just remove the "elsif ($obj->Type eq 'approval')" condition and merge
the SetStatus command with the "($obj->Type eq 'ticket')" section?

Thanks,
js.
-- 
Jean-Sebastien Morisset, Sr. UNIX Administrator <[EMAIL PROTECTED]>
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to