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);

my $children = $ticket->Members;
while (my $child = $children->Next)


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?


Never mind, figured it out. That should be