OnQueueChangeFixReminders

From Request Tracker Wiki
Jump to navigation Jump to search

This is a strange bug as it seems like reminders just lose their permission to be deleted. Actually what is happening is the reminder ticket objects are not being moved along with the tickets.

(confirmed by this post http://lists.bestpractical.com/pipermail/rt-users/2008-January/049480.html )

Edit: MarkR reports that this fix does not seem to be necessary in RT 3.8.x

  • Description: ''Fix reminders on queue change''
  • Condition: ''On Queue Change''
  • Action: ''User Defined''
  • Template: ''Global template: Blank''
  • Stage: ''TransactionCreate''
  • Custom condition: (blank)
  • Custom action preparation code: (blank)
  • Custom action cleanup code:
 my $tickets = new RT::Tickets(RT->SystemUser)
 my $id = $self->TicketObj->id;
 my $queue = $self->TicketObj->QueueObj->Name;
 
 return 1 unless (defined($id)); # Can this be undefined?
 
 $tickets->FromSQL('Type = "reminder" AND RefersTo="'.$id.'"');
 while (my $ticket = $tickets->Next) {
   $RT::Logger->info("Moving associated reminder ticket '".$ticket->id."' to queue '$queue'");
   $ticket->SetQueue($queue);
 }
 
 return 1;