I’ve just got 2 more small hurdles to clear before I should have a
working RT for my company. The way we want to use RT is when a new
ticket comes in our supervisor assigns it to a technician by changing
the owner. The technician would get an email notifying him/her of the
ticket including details of the ticket. One of which I’d like to be the
actual body of the ticket or history but the {$Transaction->Content()}
doesn’t work in Change Owner. Is there another way to get it put the
body of the ticket in an email? Or has this been fixed in 3.0.7?
Jarrod Flanders
A+, Network+
Computer Technician
Burrelles Information Services, LLC
I’ve just got 2 more small hurdles to clear before I should have a
working RT for my company. The way we want to use RT is when a new
ticket comes in our supervisor assigns it to a technician by changing
the owner. The technician would get an email notifying him/her of the
ticket including details of the ticket. One of which I’d like to be the
actual body of the ticket or history but the {$Transaction->Content()}
doesn’t work in Change Owner. Is there another way to get it put the
body of the ticket in an email? Or has this been fixed in 3.0.7?
I guess, this is as $Transaction->Content() refers to the CURRENT
Transaction which is the OwnerChange.
I needed the same and came up with using the following Template (bits and
pieces stolen from templ. others posted. Note! i reverse sort tickets on my
rt → newest on top, thus GotoFirstItem will actually do the opposite of
what you’d think it does - for me at least.).
The template should list the whole ticket history for transactions of type
CORRESPOND.
Template Content (watch for wrong linewraps due to emailing this):
RT-Attach-Message: yes
Ticket history (latest emails on top):
{
my $resolved_transaction;
my $resolved_message = “”;
my $last_content;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
if ($Transaction->Type eq ‘Correspond’) {
$resolved_transaction = $Transaction;
} elsif (!$Transactions->IsLast) {
$resolved_transaction = undef;
}
if ($resolved_transaction) {
my $attachments = $resolved_transaction->Attachments;
$attachments->GotoFirstItem;
while (my $message = $attachments->Next) {
next unless $message->ContentType =~
m!^(text/plain|message|text$)!i;
my $content = $message->Content;
if ($last_content eq $content) {
$content = undef; }
next unless length $content;
$last_content = $content;
my $subject = ($message->Subject || $Ticket->Subject);
my $wrapper = Text::Wrapper->new(columns=>70);
$content = $wrapper->wrap($content);
$resolved_message .= "Subject: ";
$resolved_message .= $subject;
$resolved_message .= "\n";
$resolved_message .= "From: ";
$resolved_message .= $message->CreatorObj->RealName ."
(“.$rtname.”)";
$resolved_message .= “\n”;
$resolved_message .= "Time: ";
$resolved_message .= $message->CreatedObj->AsString;
$resolved_message .= “\n”;
$resolved_message .= “\n”;
$resolved_message .= “$content\n\n”;
$resolved_message .=
“------------------------------------------------\n”;
}
}
}
$resolved_message;
}
{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
Stefan Seiz http://www.stefanseiz.com
Spamto: bin@imd.net
BTW, How do you reverse sort them permanently? Is
there a way to do this globally?
Yes, and I hope what I did is the recommend way to do it.
in /opr/rt3/lib/RT
I created an a file called “Transactions_Local.pm” which should override
“Transactions.pm”.
The files purpose is to list all ticket transactions DESCENDING which means
latest (youngest) transaction on top.
The files contents are:
use strict;
no warnings qw(redefine);
{{{ sub _Init
sub _Init {
my $self = shift;
$self->{‘table’} = “Transactions”;
$self->{‘primary_key’} = “id”;
By default, order by the date of the transaction, rather than ID.
$self->OrderBy( ALIAS => ‘main’,
FIELD => ‘Created’,
ORDER => ‘DESC’);
return ( $self->SUPER::Init(@));
}
}}}
1;
http://www.StefanSeiz.com
Spamto: bin@imd.net