Trying to implement "On Resolve Forward Ticket"

Hi all!

I am currently trying to implement a “On Resolve Forward Ticket” scrip which should automatically doing the same as the “Forward” (Ticket-)Action in the Web-User-Interface. We need this for external documentation of the history of certain tickets.

After trying but failing with different possible solutions using custom perl code in scrips and templates I am currently back to start using the following (minimal) setup:

grafik

If I Resolve a Ticket now I get the following error in the Webserver/Apache error.log :

[16200] [Mon Sep 10 20:02:51 2018] [error]: Scrip Prepare 29 died. - Can’t call method “GetHeader” on an undefined value at /usr/share/request-tracker4/lib/RT/Action/SendForward.pm line 113.

Stack:
[/usr/share/request-tracker4/lib/RT/Action/SendForward.pm:113]
[/usr/share/request-tracker4/lib/RT/ScripAction.pm:177]
[/usr/share/request-tracker4/lib/RT/Scrip.pm:637]
[/usr/share/request-tracker4/lib/RT/Scrips.pm:342]
[/usr/share/request-tracker4/lib/RT/Transaction.pm:194]
[/usr/share/request-tracker4/lib/RT/Record.pm:1686]
[/usr/share/request-tracker4/lib/RT/Ticket.pm:2646]
[/usr/share/request-tracker4/lib/RT/Ticket.pm:2340]
[/usr/share/request-tracker4/lib/RT/Ticket.pm:2286]
[/usr/share/request-tracker4/lib/RT/Record.pm:986]
[/usr/share/request-tracker4/lib/RT/Record.pm:965]
[/usr/share/request-tracker4/lib/RT/Interface/Web.pm:2846]
[/usr/share/request-tracker4/lib/RT/Interface/Web.pm:2956]
[/usr/share/request-tracker4/html/Ticket/Modify.html:97]
[/usr/share/request-tracker4/html/Ticket/autohandler:66]
[/usr/share/request-tracker4/lib/RT/Interface/Web.pm:696]
[/usr/share/request-tracker4/lib/RT/Interface/Web.pm:375]
[/usr/share/request-tracker4/html/autohandler:53] (/usr/share/request-tracker4/lib/RT/Scrip.pm:640)

RT version is RT 4.4.1-5 (Debian).

I also tried to kind of “re-engeneer” /ticket/Forward.html but could not find a solution for how to specify i.e. the TO: of the email to be generated.

Can anyone please help me with any examples or ideas on how to go on?

Thanks in advance and kind regards,
Roland

Good news, I finally found a working solution using custom commit code derived from Forward.html :slight_smile:

I will post as soon as I cleaned up the code.

SOLUTION: “Custom Action Commit Code” derived from Forward.html (NOTE: apply only with a proper Condition i.e. “On Resolve” - otherwise you may end up in an email-generation-loop because the code below itself generates a transaction which may trigger itself again and again) :

my $CustomSubject = $self->TicketObj->FirstCustomFieldValue(‘Order Type’) . " TEST - orig Subject: " . $self->TicketObj->Subject . " [" . ($self->TicketObj->QueueObj->SubjectTag || RT->Config->Get(‘rtname’)) . " #" . $self->TicketObj->id() . “]”;
my $CustomTo = ‘custom.to@example.domain’;
my $CustomContent = ‘’;
my %ARGS = (
Transaction => undef,
Subject => $CustomSubject,
To => $CustomTo,
Cc => ‘’,
Bcc => ‘’,
Content => $CustomContent,
ContentType => ‘text/plain’,
);
my $TicketObj = $self->TicketObj;
Abort( loc(“Permission Denied”) )
unless $TicketObj->CurrentUserHasRight(‘ForwardMessage’);
my $txn;
$TicketObj->Forward( Transaction => $txn, %ARGS );
return 1;