AddLastCommentToMail

From Request Tracker Wiki
Revision as of 15:03, 6 April 2016 by Admin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This code adds last comment to mail. Add code into template.

{
 my $Transactions = $Ticket->Transactions;
 $Transactions->Limit( FIELD => 'Type', VALUE => 'Comment' );
 $Transactions->OrderByCols (
               { FIELD => 'Created',  ORDER => 'DESC' },
               { FIELD => 'id',     ORDER => 'DESC' },
               );

 my $resolution_comment;
 my $CommentObj = $Transactions->First;
 if( $CommentObj && $CommentObj->id ) {
   $resolution_comment = $CommentObj->Content;
 }

 $resolution_comment;
}

NOTE: This doesn't work for "Update all tickets at once." Reported to list 8/20/2004, no acknowledgement or action or solution posted.

RT v3.4.5 - Showed the first comment for me maybe cos of $Transactions->First;

  • Method First returns the first object in a collection according to order of the collection. As you can see we order by the 'created' field with most recent comment on the top.
  • Ask question and post such comments to the MailingLists, wiki is not a discussion forum! This comment would be deleted soon.

This will set the email address and subject


To: {$Ticket->Transactions->First->Message->First->GetHeader('To');}

Subject: Resolved: {$Ticket->Subject}