Creating RT Reminders via Scrip

Hello,

I am running into an issue with a simple scrip that I want to use to
generate a reminder for the owner of a ticket when its status changes to
stalled. I have the conditions working but the action script returns
some errors. Here is the action script that I wrote according to the
RT::Date and RT::Reminders perldocs.

*my $tix = $self->TicketObj;
my $duedate = RT::Date->new($RT::SystemUser);
my $subject = “Test Subject”;
my $owner = $tix->Owner;
my $reminder = RT::Reminders->new($RT::SystemUser);

$duedate->SetToNow();
$duedate->AddDays( 3 );

$reminder->Add( Subject => $subject, Owner => $owner, Due =>
$duedate->ISO );
return 1;*

The error messages in the debug log are:*

[Wed Aug 31 16:21:27 2011] [debug]: Tried to load a bogus ticket id: ‘’
(/opt/rt4/sbin/…/lib/RT/Ticket.pm:158)
[Wed Aug 31 16:21:27 2011] [debug]: ‘’ not a recognised queue object.
(/opt/rt4/sbin/…/lib/RT/Ticket.pm:273)
[Wed Aug 31 16:21:27 2011] [debug]: RT::Ticket=HASH(0x2b986db2a320) No
queue given for ticket creation. (/opt/rt4/sbin/…/lib/RT/Ticket.pm:278)*

In the Reminders.pm file, these errors are generated from this ticket
creation object within RT::Reminders->Add:

my ( $status, $msg ) = $reminder->Create(
Subject => $args{‘Subject’},
Owner => $args{‘Owner’},
Due => $args{‘Due’},
RefersTo => $self->Ticket,
Type => ‘reminder’,
Queue => $self->TicketObj->Queue,
);

Any ideas why this might be throwing null results for $self->Ticket and
$self->TicketObj? Do I need to call the RT::Reminders->Ticket and
RT::Reminders->TicketObj methods earlier in the script? Should I not be
creating the RT::Reminders object as system user?

I’d appreciate any feedback!

Andrew Wagner
Assistant Network Administrator
aawagner@wisc.edu
265-5710
Room 370B
Wisconsin Center for Education Research (WCER)
www.wcer.wisc.edu

smime.p7s (7.24 KB)

Hello,

I am running into an issue with a simple scrip that I want to use to generate a reminder for
the owner of a ticket when its status changes to stalled. I have the conditions working but
the action script returns some errors. Here is the action script that I wrote according to
the RT::Date and RT::Reminders perldocs.

Have a look at Ticket/Reminders.html for the code that creates Reminders.
Creating an RT::Reminders object manually means that there is no
$self->TicketObj, leading to your problem.

I suspect you want $self->TicketObj->Reminders->Add(…)

-kevin