Help with perl code to resolve all children tickets

To list,

I was fooling around with the idea of creating a scrip that would allow the
resolution of a parent ticket to automatically resolve all children tickets.
I thought this would be helpful if a developer had a bunch of
sub-tasks/tickets and they didn’t want to go in and “resolve” each one
individually, they could just “resolve” the parent and that would cause a
cascade effect to go ahead and resolve all the children. This is the code I
developed:

Resolve all Ticket children when the Ticket is resolved

if (defined($id))
{
$tickets->FromSQL(‘Type = “ticket” AND MemberOf="’.$id.’"’);

Loop thru all Children

 while (my $child = $tickets->Next) {
    next unless( $child->Status =~ /^(?:new|open|stalled)$/ );
    $RT::Logger->info("Closing associated child");
    $child->SetStatus("resolved");

This worked fine except in the situation where a “Child” ticket was also a
"Depends/on" ticket. The cascade stops. Well, that made sense, but I want to
get around that.

So I tried to force it with:

Resolve all Ticket children when the Ticket is resolved



$child->SetStatus(“resolved”, ‘Force’);

This didn’t work. The top parent was resolved, but no cascade effect to
any of the “child” tickets at all, even when there was no "DependsOn"
relationship.

I looked at the log and it shows the first ticket resolved, but no errors
after that and yet, the children weren’t resolved.

Without the “Force”, it works just fine, up to the ticket with the
"DependsOn"child.

So … I went to several Perl handbooks (Perl Cookbook by O’Reilly, Perl
for Dummies, etc.) and found nothing on the “Set” command, let alone the
"Force" option.
I went to the RT Essentials book and found nothing.

I am NOT a perl programmer, but understand enough basic perl to be able to
clone a scrip or two and modify it with what little perl knowledge(?) I
have.

Obviously, I don’t know enough about perl to figure this one out.

Can anyone help me out with some perl clues/instruction here?

Thanks in advance.

Kenn
LBNL

Hey everyone.

I have a few n00b questions for you on a new-ish RT 3.8.8 install:

I have created a custom field labeled ‘Send to:’, where there is a dropdown
list naming several queues. What I’m wondering is when selecting these
options & updating the ticket, if it could then create a child ticket in the
queue selected via the custom field dropdown menu with the content that
current reply / comment which would then be dependent on the ‘master’ ticket
of sorts.

— Similar to http://www.gossamer-threads.com/lists/rt/users/68537? ,But
different enough to require a separate answer,

Let me know if you can,

Kris Germann
Fibernetics Corporation

I should clarify because this sounds ridiculous the way I’ve wrote it,
sorry:

I am creating let’s say. a order. I want to create it in Queue A, but
Queues B, E, and G need to be notified about it; lets say one is shipping,
one provisioning etc. So I want to comment / reply on the ticket, then have
the ability to select queues B, E, and K and hit update, when this happens,
it creates child tickets dependant on the original ticket and each with a
subject suffix like below:Subject: {$Tickets{‘TOP’}->Subject} - ChildTicketSuffix

Depended-on-by: TOP

Status: new

Queue: Queue B, Queue E, Queue G

Type: ticket

Refers-To: {$Tickets{‘TOP’}->Id()}

Content: {$Transaction->Content}

ENDOFCONTENT

Thanks

Kris Germann
Fibernetics Corporation

From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Kris Germann
Sent: Monday, January 24, 2011 3:25 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Custom fields generating child tickets

Hey everyone.

I have a few n00b questions for you on a new-ish RT 3.8.8 install:

I have created a custom field labeled ‘Send to:’, where there is a dropdown
list naming several queues. What I’m wondering is when selecting these
options & updating the ticket, if it could then create a child ticket in the
queue selected via the custom field dropdown menu with the content that
current reply / comment which would then be dependent on the ‘master’ ticket
of sorts.

— Similar to http://www.gossamer-threads.com/lists/rt/users/68537? ,But
different enough to require a separate answer,

Let me know if you can,

Kris Germann
Fibernetics Corporation

To list,

I was fooling around with the idea of creating a scrip that would allow the resolution of a
parent ticket to automatically resolve all children tickets. I thought this would be helpful
if a developer had a bunch of sub-tasks/tickets and they didn’t want to go in and "resolve"
each one individually, they could just “resolve” the parent and that would cause a cascade
effect to go ahead and resolve all the children. This is the code I developed:

Resolve all Ticket children when the Ticket is resolved

if (defined($id))
{
$tickets->FromSQL(‘Type = “ticket” AND MemberOf="’.$id.’"’);

Loop thru all Children

while (my $child = $tickets->Next) {
next unless( $child->Status =~ /^(?:new|open|stalled)$/ );
$RT::Logger->info(“Closing associated child”);
$child->SetStatus(“resolved”);

This worked fine except in the situation where a “Child” ticket was also a "Depends/on"
ticket. The cascade stops. Well, that made sense, but I want to get around that.

So I tried to force it with:

Resolve all Ticket children when the Ticket is resolved



$child->SetStatus(“resolved”, ‘Force’);

This didn’t work. The top parent was resolved, but no cascade effect to any of the "child"
tickets at all, even when there was no “DependsOn” relationship.

I looked at the log and it shows the first ticket resolved, but no errors after that and yet,
the children weren’t resolved.

Without the “Force”, it works just fine, up to the ticket with the "DependsOn"child.

So … I went to several Perl handbooks (Perl Cookbook by O’Reilly, Perl for Dummies, etc.)
and found nothing on the “Set” command, let alone the “Force” option.
I went to the RT Essentials book and found nothing.

The relevant documentation is found in perldoc
lib/RT/Ticket_Overlay.pm . You’re passing incorrect arguments to
SetStatus

Kevin,

AHHH. I’ll check it out.

Thanks.

Kenn
LBNLOn Mon, Jan 24, 2011 at 6:59 PM, Kevin Falcone falcone@bestpractical.comwrote:

On Mon, Jan 24, 2011 at 12:06:02PM -0800, Kenneth Crocker wrote:

To list,

I was fooling around with the idea of creating a scrip that would
allow the resolution of a
parent ticket to automatically resolve all children tickets. I thought
this would be helpful
if a developer had a bunch of sub-tasks/tickets and they didn’t want
to go in and "resolve"
each one individually, they could just “resolve” the parent and that
would cause a cascade
effect to go ahead and resolve all the children. This is the code I
developed:

Resolve all Ticket children when the Ticket is resolved

if (defined($id))
{
$tickets->FromSQL(‘Type = “ticket” AND MemberOf="’.$id.’"’);

Loop thru all Children

while (my $child = $tickets->Next) {
next unless( $child->Status =~ /^(?:new|open|stalled)$/ );
$RT::Logger->info(“Closing associated child”);
$child->SetStatus(“resolved”);

This worked fine except in the situation where a “Child” ticket was
also a "Depends/on"
ticket. The cascade stops. Well, that made sense, but I want to get
around that.

So I tried to force it with:

Resolve all Ticket children when the Ticket is resolved



$child->SetStatus(“resolved”, ‘Force’);

This didn’t work. The top parent was resolved, but no cascade effect
to any of the "child"
tickets at all, even when there was no “DependsOn” relationship.

I looked at the log and it shows the first ticket resolved, but no
errors after that and yet,
the children weren’t resolved.

Without the “Force”, it works just fine, up to the ticket with the
"DependsOn"child.

So … I went to several Perl handbooks (Perl Cookbook by O’Reilly,
Perl for Dummies, etc.)
and found nothing on the “Set” command, let alone the “Force” option.
I went to the RT Essentials book and found nothing.

The relevant documentation is found in perldoc
lib/RT/Ticket_Overlay.pm . You’re passing incorrect arguments to
SetStatus

I am NOT a perl programmer, but understand enough basic perl to be
able to clone a scrip or
two and modify it with what little perl knowledge(?) I have.

Obviously, I don’t know enough about perl to figure this one out.

Can anyone help me out with some perl clues/instruction here?

Thanks in advance.

Kenn
LBNL