[rt-users] Creating RT Reminders via Scrip

Kevin Falcone falcone at bestpractical.com
Wed Aug 31 18:54:58 EDT 2011


On Wed, Aug 31, 2011 at 11:36:01AM -0500, Andrew Wagner wrote:
>    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

>    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
>  [1]aawagner at wisc.edu
>  265-5710
>  Room 370B
>  Wisconsin Center for Education Research (WCER)
>  [2]www.wcer.wisc.edu
> 
> References
> 
>    Visible links
>    1. mailto:aawagner at wisc.edu
>    2. http://www.wcer.wisc.edu/



> --------
> RT Training Sessions (http://bestpractical.com/services/training.html)
> *  Chicago, IL, USA ? September 26 & 27, 2011
> *  San Francisco, CA, USA ? October 18 & 19, 2011
> *  Washington DC, USA ? October 31 & November 1, 2011
> *  Melbourne VIC, Australia ? November 28 & 29, 2011
> *  Barcelona, Spain ? November 28 & 29, 2011

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110831/8c7d217c/attachment.sig>


More information about the rt-users mailing list