Hi Aaron, Thanks for sharing your scrip. I think your scrip is similar but not quite what I was wanting to do. Yours seems hardcoded to only check for two child tickets. I would like my scrip to loop through all child tickets and change the status of the parent if all child tickets are resolved…
Does anyone have any pointers? I can’t see where this is falling down. Thanks, Jon ----------------------------------------------------- Jon Witts Director of Digital Strategy Queen Margaret's School Escrick Park York YO19 6EU Telephone: 01904 727600 Fax: 01904 728150 Website: www.queenmargarets.com<http://www.queenmargarets.com/> From: Aaron Guise [mailto:[email protected]] Sent: 18 May 2015 00:55 To: Jon Witts; [email protected] Subject: Re: [rt-users] Help with Scrip for child / dependent tickets Hi Jon, I had a similar requirement I suppose. I had an original (Parent) ticket and this ticket has two dependent tickets at a certain stage before proceeding down the rest of the workflow. I achieved this requirement by having a scrip running when the dependent tickets are completed to check whether the other dependent is closed and if it is then to progress the parent ticket status. I think effectively it is probably the same general thing you are trying to do. This is the custom action from my scrip. my $CurrentUser = RT::CurrentUser->new( $self->TransactionObj->Creator ); # Put actions in scope of our user my $Ticket = new RT::Ticket($CurrentUser);# New ticket object $Ticket ->load( $self->TicketObj->id ); my $MemberOf = $self->TicketObj->DependedOnBy; # Find the Parent Ticket Identifier. my $Link = $MemberOf->Next; # Get the Link for Parent Object. my $Parent = new RT::Ticket($CurrentUser); # New Parent ticket object $Parent->load( $Link->BaseObj->id ); my $Queue = $Parent->QueueObj; my $children = new RT::Tickets( $CurrentUser ); $children->LimitDependedOnBy ($Parent->id); my $complete = 0; while (my $child = $children->Next){ if ($child->Status eq 'Completed'){ $complete = $complete + 1; } } if ( $complete == 2 ) { # Both tickets are completed so we can progress $Parent->SetStatus('In Progress-Allocate Resources'); $Parent->Comment( 'Content' => 'Design/Consent phase completed'); } -- Regards, Aaron On Sat, May 9, 2015 at 2:03 AM Jon Witts <[email protected]<mailto:[email protected]>> wrote: Hi there, We are wanting to have a scrip run on our queues which will move a ticket back to the "open" state if all of its child and dependent tickets are closed (resolved, rejected or deleted). I have found Ruslan's scrip which opens a ticket once all of its child tickets are closed here on the wiki: http://requesttracker.wikia.com/wiki/OpenTicketOnAllMemberResolve which works great. However we have tried to edit this to work on depending / dependent tickets but cannot get it working. Here is the scrip, can anyone see what we are missing? ---------------------------- # end if setting this ticket to "resolved, deleted or rejected" return 1 if ($self->TransactionObj->NewValue !~ /^(?:resolved|deleted|rejected)$/); # current ticket is a dependant of (Depended on by some parents) my $DependedOnBy = $self->TicketObj->DependedOnBy; while( my $l = $DependedOnBy->Next ) { # we can't check non local objects next unless( $l->TargetURI->IsLocal ); # if dependant ticket is not in active state then scrip can skip it next unless( $l->TargetObj->Status =~ /^(?:new|open|stalled|pending|planning|holiday)$/ ); # the dependant ticket has dependencies (current ticket is one of them) my $ds = $l->TargetObj->DependsOn(); my $flag = 0; while( my $d = $ds->Next ) { next unless( $d->BaseURI->IsLocal ); next unless( $d->BaseObj->Status =~ /^(?:new|open|stalled|pending|planning|holiday)$/ ); $flag = 1; last; } # shouldn't open dependant if some dependency is active next if( $flag ); # All dependent tickets closed - open depending ticket $l->TargetObj->SetStatus('open'); } return 1; ------------------ Once we can get this scrip working we would ideally like a single scrip which will check all tickets on status change to see if it has a parent or depending ticket; and then if all child or dependent tickets for its parent are closed, to reopen the parent... Any help greatly received! Jon ----------------------------------------------------- Jon Witts Director of Digital Strategy Queen Margaret's School Escrick Park York YO19 6EU Telephone: 01904 727600 Fax: 01904 728150 Website: www.queenmargarets.com<http://www.queenmargarets.com> This email has been processed by Smoothwall Anti-Spam - www.smoothwall.net<http://www.smoothwall.net>
