ForwardWithMessage

From Request Tracker Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

You can't forward a ticket or transaction with a message for the recipient. To change that:

  • Insert a textarea for the message on Forward-Page:
Copy /html/Ticket/Forward.html to /local/html/Ticket/Forward.html
Open /local/html/Ticket/Forward.html and insert after

a new table-row with a textarea for the message:

<&|/l&>Message:

    
  • Send message per Mail and store it in the Forward-Transaction:
Create /local/lib/RT/Interface/Email_Local.pm and add following content. (Differences to Email.pm are bold)

use strict; no warnings qw(redefine); package RT::Interface::Email; use Email::Address; use MIME::Entity; use RT::EmailParser; use File::Temp; use UNIVERSAL::require; use Mail::Mailer (); use Text::ParseWords qw/shellwords/; sub ForwardTransaction { my $txn = shift; my %args = ( To => , Cc => , Bcc => , Message => , @_ ); my $entity = MIME::Entity->build( Type => 'multipart/mixed', Description => 'forwarded transaction', ); my $mimeMessage = MIME::Entity->build( Type => 'text/plain; charset="utf-8"', Data => $args{Message} ); $entity->add_part($mimeMessage); $entity->add_part($txn->ContentAsMIME); my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Transaction => $txn ); if ($ret) { my $ticket = $txn->TicketObj; my ( $ret, $msg, $createdTrans ) = $ticket->_NewTransaction( Type => 'Forward Transaction', Field => $txn->id, Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc}, ); #Attach message for Recipients to Transaction $createdTrans->_Attach( MIME::Entity->build( Type => 'text/plain', Data => $args{Message}) ); unless ($ret) { $RT::Logger->error("Failed to create transaction: $msg"); } } return ( $ret, $msg ); } sub ForwardTicket { my $ticket = shift; my %args = ( To => , Cc => , Bcc => , Message=>, @_ ); my $txns = $ticket->Transactions; $txns->Limit( FIELD => 'Type', VALUE => $_, ) for qw(Create Correspond); my $entity = MIME::Entity->build( Type => 'multipart/mixed', Description => 'forwarded ticket', ); my $mimeMessage = MIME::Entity->build( Type => 'text/plain; charset="utf-8"', Data => $args{Message} ); $entity->add_part($mimeMessage); $entity->add_part( $_ ) foreach map $_->ContentAsMIME, @{ $txns->ItemsArrayRef }; my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Ticket => $ticket, Template => 'Forward Ticket', ); if ($ret) { my ( $ret, $msg, $createdTrans ) = $ticket->_NewTransaction( Type => 'Forward Ticket', Field => $ticket->id, Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc} ); #Attach message for Recipients to Transaction $createdTrans->_Attach($mimeMessage); unless ($ret) { $RT::Logger->error("Failed to create transaction: $msg"); } } return ( $ret, $msg ); } 1; That's it. Hopefully it helps someone.