On Create Forward an email?

Hi guys!

I want to create a custom scrip to forward a ticket (including the attachment) upon creation if the subject line matches a certain criteria. Could someone please point me in the right direction?

Here’s my prep code:

if( $self->TicketObj->Subject =~ "test" ) {
   my $txn = $self->TransactionObj;
   $self->TicketObj->Forward( Transaction => $txn, To => 'myemail@example.com' );
   return 1;
}
return 0;

It’s not working, and I’m not sure what the issue is, as I’m following the docs for RT::Ticket::Forward (RT::Ticket - RT 5.0.1 Documentation - Best Practical)

Could anyone provide some guidance?

Thanks

Does it work if you use a custom condition that checks if the subject matches and the transaction is a ticket create transaction, then you use the “Send Forward” existing action? I am not sure how the recipient is set though for that action

Thank you for your reply, @knation. Unfortunately, we’re using an older version of RT that does not have the “Send Forward” action.

Gotcha. Is there any logging when the scrip doesn’t work?

You should be able to grab the result of Forward and log it:

my ($ret, $msg) =    $self->TicketObj->Forward( Transaction => $txn, To => 'myemail@example.com' );

RT::Logger->error("Result of forward: $msg");