Alex Peters, Fri, 26 Mar 2010 11:51:50 +1100:
Does anyone have a usage example of the SendEmail or Notify
modules to offer here?  Failing that, a way to get a
Transaction object from a ticket might be enough (but I admit
that I barely know what I'm doing at this early stage).

Here's what I'm doing to generate the comment:

    my $id = $ticket->Id;
    my $action_obj = RT::Action::RecordComment->new(
        Argument       => undef,
        CurrentUser    => $user,
        ScripActionObj => $void_scrip_action,
        ScripObj       => $void_scrip,
        TemplateObj    => $template,
        TicketObj      => $ticket,
        TransactionObj => undef,
    );
    warn "$id: preparation failed\n"
        if not $action_obj->Prepare;
    warn "$id: commit failed\n"
        if not $action_obj->Commit;

I've had some more time to look into this, and I'm now using
the RT::Action::Notify module in this way from my external
script:

    my $id = $ticket->Id;
    my (undef, undef, $trans_obj)
        = $ticket->_NewTransaction( Type => '' );
    my $action_obj = RT::Action::Notify->new(
        Argument       => 'Owner,AdminCc',
        CurrentUser    => $user,
        ScripActionObj => $void_scrip_action,
        ScripObj       => $void_scrip,
        TemplateObj    => $template,
        TicketObj      => $ticket,
        TransactionObj => $trans_obj,
    );
    warn "$id: preparation failed\n"
        if not $action_obj->Prepare;
    warn "$id: commit failed\n"
        if not $action_obj->Commit;

I'm sure that using a private method is not the best way to
achieve the outcome of sending an email and noting it in the
ticket.  Can anyone offer a cleaner solution than this?

--
Cheers,
Alex

Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Reply via email to