[rt-users] Help with Scrip for child / dependent tickets
Jon Witts
jwitts at queenmargarets.com
Fri May 8 10:03:28 EDT 2015
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
This email has been processed by Smoothwall Anti-Spam - www.smoothwall.net
More information about the rt-users
mailing list