[rt-users] Approvals made, change status of orignal ticket

Kevin Squire gentgeen at linuxmail.org
Fri Jun 1 15:51:57 EDT 2007


Now I have a follow-up issue.  Apparently my OpenDendentsOnResolve is 
not working like I wanted.

As a recap:
I have two queues "TimeOff" and TimeOff-Approval"
(TimeOff-Approval is "disabled" like the ___Approval queue.  Not sure if
that is a real problem or not, does not seem to be).  A staff member 
opens a ticket in "TimeOff" and that creates the two tickets in 
"TimeOff-Approval" that the Supervisor and HR need to sign off on first.

Thanks to Gene, The Ticket created in "TimeOff" gets a status "pending"
(I added a new status to my RT_SiteConfig.pm)
--------------------

Now once the two "TimeOff-Approval" tickets are resolved, I want the
"TimeOff" ticket's status to be changed to "open". As of right now, the "TimeOff" ticket remains "pending" even after approvals are approved.

I copy/pasted the "When a ticket has been approved by all approvers, add
correspondence to the original ticket" from the ___Approval queue.

I image this is where I can add the code needed to change the ticket
from "pending" to "open" but I don't know how. 

---------------------
FROM THE "When a ticket has been approved by all approvers, add
correspondence to the original ticket"


CONDITION: On Resolve
ACTION: User Defined
TEMPLATE: All Approvals Passed
STAGE: TransactionCreate
CUSTOM CONDTION: blank
CUSTOM ACTION PREPARATION CODE:
# ------------------------------------------------------------------- #
# 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 !@TOP) {
	    $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;
# ------------------------------------------------------------------- #

CUSTOM ACTION CLEANUP CODE: blank


-- 
http://gentgeen.homelinux.org

#############################################################
 Associate yourself with men of good quality if you esteem    
 your own reputation; for 'tis better to be alone then in bad 
 company.        - George Washington, Rules of Civility



More information about the rt-users mailing list