Difference between revisions of "AddLastCommentToMail"

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
m
 
Line 1: Line 1:
This code adds last comment to mail. Add code into template.
This code adds last comment to mail. Add code into template.
 
<pre>
  {
  {
   my $Transactions = $Ticket-&gt;Transactions;
   my $Transactions = $Ticket-&gt;Transactions;
Line 18: Line 18:
  }
  }
   
   
</pre>


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

Latest revision as of 15:30, 14 August 2016

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}