[rt-users] Deleting tickets recursively

Paul Tomblin ptomblin at xcski.com
Tue May 1 09:45:13 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20120501/4c98368f/attachment.htm>


More information about the rt-users mailing list