<div dir="ltr"><div><div><div><div>Hi Jon, <br><br></div>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. <br><br>This is the custom action from my scrip.<br><br>my $CurrentUser = <br> RT::CurrentUser->new( $self->TransactionObj->Creator );<br># Put actions in scope of our user<br>my $Ticket = <br> new RT::Ticket($CurrentUser);# New ticket object<br>$Ticket<br> ->load( $self->TicketObj->id );<br>my $MemberOf =<br> $self->TicketObj->DependedOnBy; # Find the Parent Ticket Identifier.<br>my $Link = $MemberOf->Next; # Get the Link for Parent Object.<br>my $Parent = new RT::Ticket($CurrentUser); # New Parent ticket object<br>$Parent->load( $Link->BaseObj->id );<br>my $Queue = $Parent->QueueObj;<br><br>my $children = new RT::Tickets( $CurrentUser );<br> $children->LimitDependedOnBy ($Parent->id);<br><br>my $complete = 0;<br> <br>while (my $child = $children->Next){<br> if ($child->Status eq 'Completed'){<br> $complete = $complete + 1;<br> }<br>}<br> <br>if ( $complete == 2 ) {<br> # Both tickets are completed so we can progress<br> $Parent->SetStatus('In Progress-Allocate Resources');<br> $Parent->Comment( 'Content' => 'Design/Consent phase completed');<br>}<br> <br></div>--<br></div>Regards, <br><br></div>Aaron<br></div><br><div class="gmail_quote">On Sat, May 9, 2015 at 2:03 AM Jon Witts <<a href="mailto:jwitts@queenmargarets.com">jwitts@queenmargarets.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi there,<br>
<br>
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).<br>
<br>
I have found Ruslan's scrip which opens a ticket once all of its child tickets are closed here on the wiki: <a href="http://requesttracker.wikia.com/wiki/OpenTicketOnAllMemberResolve" target="_blank">http://requesttracker.wikia.com/wiki/OpenTicketOnAllMemberResolve</a> 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?<br>
<br>
----------------------------<br>
<br>
# end if setting this ticket to "resolved, deleted or rejected"<br>
return 1 if ($self->TransactionObj->NewValue !~ /^(?:resolved|deleted|rejected)$/);<br>
<br>
# current ticket is a dependant of (Depended on by some parents)<br>
my $DependedOnBy = $self->TicketObj->DependedOnBy;<br>
while( my $l = $DependedOnBy->Next ) {<br>
# we can't check non local objects<br>
next unless( $l->TargetURI->IsLocal );<br>
# if dependant ticket is not in active state then scrip can skip it<br>
next unless( $l->TargetObj->Status =~ /^(?:new|open|stalled|pending|planning|holiday)$/ );<br>
<br>
# the dependant ticket has dependencies (current ticket is one of them)<br>
my $ds = $l->TargetObj->DependsOn();<br>
<br>
my $flag = 0;<br>
while( my $d = $ds->Next ) {<br>
next unless( $d->BaseURI->IsLocal );<br>
next unless( $d->BaseObj->Status =~ /^(?:new|open|stalled|pending|planning|holiday)$/ );<br>
$flag = 1;<br>
last;<br>
}<br>
# shouldn't open dependant if some dependency is active<br>
next if( $flag );<br>
# All dependent tickets closed - open depending ticket<br>
$l->TargetObj->SetStatus('open');<br>
}<br>
<br>
return 1;<br>
<br>
------------------<br>
<br>
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...<br>
<br>
Any help greatly received!<br>
<br>
Jon<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Jon Witts<br>
Director of Digital Strategy<br>
Queen Margaret's School<br>
Escrick Park<br>
York YO19 6EU<br>
<br>
Telephone: 01904 727600<br>
Fax: 01904 728150<br>
<br>
Website: <a href="http://www.queenmargarets.com" target="_blank">www.queenmargarets.com</a><br>
<br>
<br>
This email has been processed by Smoothwall Anti-Spam - <a href="http://www.smoothwall.net" target="_blank">www.smoothwall.net</a><br>
<br>
</blockquote></div>