Displaying Comments in Templates

{$Ticket->Transactions->First->Content()} displays the first comment
of a ticket in a template. Is there a way to get it to display the
last one?

Andy Harrison
(full headers for details)

{$Ticket->Transactions->First->Content()} displays the first comment
of a ticket in a template. Is there a way to get it to display the
last one?


Andy Harrison
(full headers for details)

I’m trying this snippet to get the last comment on a ticket. It
doesn’t display any errors, but the between the — dashes is blank in
the e-mail.

Template Content:

last comment:
{
my $resolution_comment;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
if ($Transaction->Type eq ‘Correspond’) {
$resolution_comment = $Transaction->First->Content;
last;
}
}
$OUT .= $resolution_comment;
$OUT;
}

Andy Harrison
(full headers for details)

I’m trying this snippet to get the last comment on a ticket. It
doesn’t display any errors, but the between the — dashes is blank in
the e-mail.

Template Content:

last comment:

{
my $resolution_comment;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
if ($Transaction->Type eq ‘Correspond’) {
$resolution_comment = $Transaction->First->Content;
last;
}
}
$OUT .= $resolution_comment;
$OUT;
}

I tried simplifying it and shortening it to:

{
$Ticket->Transactions->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
$Ticket->Transactions->GotoFirstItem;
$Ticket->Transactions->First->Content();
}

But that doesn’t cut it. $Ticket->Transactions->First->Content();
still shows the real first comment;

Any ideas?

Andy Harrison
(full headers for details)

Andy Harrison wrote:

last comment:

{
my $resolution_comment;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
if ($Transaction->Type eq ‘Correspond’) {
$resolution_comment = $Transaction->First->Content;
last;
}
}
$OUT .= $resolution_comment;
$OUT;
}

The “last” in the loop there sounds like exactly what you
don’t want…
�|� Request Tracker — Best Practical Solutions – Trouble Ticketing. Free.

The “last” in the loop there sounds like exactly what you
don’t want…

Nope, that’s what I want. I want the comment that was filled out
while resolving the ticket.

Andy Harrison
(full headers for details)

The “last” in the loop there sounds like exactly what you
don’t want…

Oops, didn’t look at the quoted text closely enough. I put a working
snippet in the wiki.

Andy Harrison
(full headers for details)