Having the last transaction (or the full ticket) in emails on queue or owner changes

Hi,

This is a question I have for a while. In the templates, using
{$Transaction->Content()} is usually ok for create/reply/comment
because there is something in the transaction.

When I change the ticket from a queue to another or change the owner,
{$Transaction->Content()} is empty. So people receive by email
basically “queue changed” or “owner changed” info, but they have to
check in the web interface what the ticket is about.

Do you have any idea how I can add more info about the ticket in this
kind of emails? I mean putting at least the last transaction content
in the template or maybe the first text content of the ticket (usually
it’s the request), or maybe a part/all of the ticket history (with
something we can take from the forward feature maybe) ?

Thanks,
L.B.

Hi,

This is a question I have for a while. In the templates, using
{$Transaction->Content()} is usually ok for create/reply/comment
because there is something in the transaction.

When I change the ticket from a queue to another or change the owner,
{$Transaction->Content()} is empty. So people receive by email
basically “queue changed” or “owner changed” info, but they have to
check in the web interface what the ticket is about.

Do you have any idea how I can add more info about the ticket in this
kind of emails? I mean putting at least the last transaction content
in the template or maybe the first text content of the ticket (usually
it’s the request), or maybe a part/all of the ticket history (with
something we can take from the forward feature maybe) ?

There should be examples in the mailing list archive and the wiki for
doing this. A quick google found:


as well as some recent posts to the mailing list.

-kevin

Thanks Kevin, I searched the wiki but didn’t find this page.

Here is what I did for my problem. It only print the last
correspondance/comment. This is sent in my case to the owner for an
owner change, and to the adminccs of the queue for a queue change.

To put in the template used for owner change or queue change:

{
my $txns = $Ticket->Transactions;
$txns->Limit(
FIELD => ‘Type’,
VALUE => $_,
) for qw(Create Correspond Comment);

my $last_content;
my $AttachmentObjects = $txns->Last()->Attachments;
while( my $at = $AttachmentObjects->Next()){
next if $at->ContentType !~ m!^(text/html|text/plain|message|text$)!i;
$last_content = $at->Content;
}
$last_content =~ s/<(([^ >]|\n)*)>//g; # strip HTML tags from text/html
$last_content;
}

Looks ok so far…

L.B.

Here is a version a bit improved :

Last correspondence of the ticket:

{
my $txns = $Ticket->Transactions;
$txns->Limit(
FIELD => ‘Type’,
VALUE => $_,
) for qw(Create Correspond Comment);

my $last_content;
my $AttachmentObjects = $txns->Last()->Attachments;
while( my $at = $AttachmentObjects->Next()){
next if $at->ContentType !~ m!^(text/html|text/plain|message|text$)!i;
$last_content = $at->Content;
}

$html = HTML::TreeBuilder->new();
$html->parse($last_content);
$formatter = HTML::FormatText->new(leftmargin => 0, rightmargin => 50);
$formatter->format($html);

}

L.B.