[rt-users] Approved tickets not 'opened'...

Kenneth Crocker KFCrocker at lbl.gov
Mon Feb 11 13:44:59 EST 2008


Jean-Sebastien,

	We use the following scrip for notifying the requestor that the ticket 
has been approved:

# condition execution on CF Review Process

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if  ($trans->Type eq 'CustomField')
     {my $cf = new RT::CustomField($RT::SystemUser);
         $cf->LoadByName(Queue => $ticket->QueueObj->id,
          Name => "Review Process");
      return 0 unless $cf->id;
      if  ($trans->Field == $cf->id &&
           $trans->NewValue eq "Review Complete-Approved")
           {
            return 1;
           }
     }

return 0;

	Then we follow that with another scrip that "modifies" ticket info, 
that is triggered by the same CF change:

#----------------------------------------------------------------------------
# Custom action preparation code:
#----------------------------------------------------------------------------

return 1;

#----------------------------------------------------------------------------
# Custom action cleanup code:
#----------------------------------------------------------------------------

# set new Ticket Owner value

my $Ticket = $self->TicketObj;
$Ticket->SetStatus("new");
$Ticket->SetOwner(10, 'Force');
return 1;

	We like to wait before transferring the ticket to it's queue because we 
don't like the support queue to have too many tickets not being worked 
on. However, if we did want it to automatically transfer we would add 
code to set the queue.

	Of course, you may want a different result. We want the ticket to be 
owned by "nobody" because we don't know who it will be assigned to and 
we want it to stay as "new" until the owner (when assigned) actually 
opens it for work and since he may be working on several tickets, that 
may not happen right away. When the ticket does get opened, we send 
another notification to the requestor letting them know the new status. 
Hope this helps.


Kenn
LBNL


On 2/11/2008 7:03 AM, Jean-Sebastien Morisset wrote:
> 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 !@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;
> ---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.




More information about the rt-users mailing list