AddLastCommentToMail

From Request Tracker Wiki
Jump to: navigation, 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];}

Subject: Resolved: {$Ticket->Subject}