How to get ticket associated with a reminder?

RT newb here, I’m trying to write a script to gather and collate reminders to send batch notifications ( slack, email, etc ) to users with reminders.

The heart of the script is
my $tickets = RT::Tickets->new($RT::SystemUser);
my $search = RT::Search::FromSQL->new(
TicketsObj => $tickets,
Argument => ‘Type = “reminder” and (Status = “open” or Status = “new”)’,
);
$search->Prepare();

my $reminders;

while ( my $ticket = $tickets->Next() ) {
    push( @{ $reminders->{ $ticket->Owner() }->{reminders} }, $ticket );
}

Here you can see I’m pulling the reminders, but upon inspection of the objects ( using Data::Dumper ), I’m not seeing any way to access the associated actual ticket related to the reminder. Is there any way to do this? I’ve spent a few hours searching but haven’t come up with anything useful.

Thanks!

1 Like

This may be a little off base here but can you do something like this:

while ( my $ticket = $tickets->Next ) {
   my $reminders = $ticket->Reminders;

   // Not sure off the top of my head if Next works here
   while ( my $reminder = $reminders->Next ) {
      // Do something with the reminder 
  }
}

Thanks for the reply!

In my loop, the “ticket” is actually the reminder itself. Think of it as

while ( my $reminder = $reminders->Next() ) {
    my $ticket = $reminder->SOMETHING;
}

It’s that something that I don’t know. If I understand our code, it assumes I have the ticket and want the reminders, but instead I have the reminder and want the tickets.

Is the parent ticket a link on the reminder?