Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Users

Deleting tickets recursively

 

 

Request Tracker users RSS feed   Index | Next | Previous | View Threaded


ptomblin at xcski

May 1, 2012, 6:45 AM

Post #1 of 2 (187 views)
Permalink
Deleting tickets recursively

I have a script that creates a ticket, then one or more child tickets of
that ticket in a different queue, and then one or more child tickets of
them in yet another queue. I also wrote a test to call that script and
then verify that the expected tickets exist, etc. However, when I try to
clean up at the end of the test, I have a sub that takes the top level
ticket and recurses down through the children trying to delete them, but
unfortunately only the top level one gets deleted. Here's the code:


sub recursiveDelete {
my $ticketId = shift;

my $ticket = RT::Ticket->new(RT::SystemUser);
$ticket->Load($ticketId);

my $children = $ticket->Members;
while (my $child = $children->Next)
{
recursiveDelete($child->id);
}

$ticket->Delete;
}

I traced through it in the perl debugger, and the problem appears to be in
Ticket::SetStatus('deleted') where it calls $self->__Value('status') and it
returns 'deleted'. So it thinks it's already deleted and doesn't change
the status. Any suggestions why this is happening?

--
http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin


ptomblin at xcski

May 1, 2012, 8:34 AM

Post #2 of 2 (169 views)
Permalink
Re: Deleting tickets recursively [In reply to]

On Tue, May 1, 2012 at 9:45 AM, Paul Tomblin <ptomblin [at] xcski> wrote:

> recursiveDelete($child->id);
>

Never mind, figured it out. That should be
"recursiveDelete($child->BaseObj->id);"

--
http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin

Request Tracker users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.