<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Cambria;
panose-1:2 4 5 3 5 4 6 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Aaron,<o:p></o:p></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">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…<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Does anyone have any pointers? I can’t see where this is falling down.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Thanks,<br>
Jon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">-----------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Jon Witts<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Director of Digital Strategy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Queen Margaret's School<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Escrick Park<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">York YO19 6EU<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Telephone: 01904 727600<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Fax: 01904 728150<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">Website:
</span><a href="http://www.queenmargarets.com/"><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#0563C1">www.queenmargarets.com</span></a><span style="font-size:11.0pt;font-family:"Cambria",serif;color:#1F497D">
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Aaron Guise [mailto:aaron@guise.net.nz]
<br>
<b>Sent:</b> 18 May 2015 00:55<br>
<b>To:</b> Jon Witts; rt-users@lists.bestpractical.com<br>
<b>Subject:</b> Re: [rt-users] Help with Scrip for child / dependent tickets<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Jon, <o:p></o:p></p>
</div>
<p class="MsoNormal">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>
<o:p></o:p></p>
</div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Regards, <o:p></o:p></p>
</div>
<p class="MsoNormal">Aaron<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Sat, May 9, 2015 at 2:03 AM Jon Witts <<a href="mailto:jwitts@queenmargarets.com">jwitts@queenmargarets.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt">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><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>