Send last message/comment from ticket to requestor on resolve

Hi,

Wondering how to do this:

When I resolve a ticket, I want RT to send the message I put in the
resolve to the requestor, and not the default “as per our records…”

Nelson Pereira
Senior Network Administrator

Protus IP Solutions Inc.
npereira@protus.com
phone: 613.733.0000 ext.528
MyFax: 613.822.5083

Refer your friends and colleagues to MyFax!
Click here for more information.
http://www.myfax.com/referral_program.asp

http://www.myfax.com

Nelson,

Here’s how I include the resolver’s message with our standard “resolved”
blurb. This is my (slightly modified) template for OnResolve. The guts of
what you want to do is that I grab the last correspondence, compare it to
the last outgoing e-mail (don’t include it if they’re the same), then see
if it’s incoming e-mail (don’t include it if so). If it passes those
tests, then I include it in my standard blurb to the requestor. There are
probably cleaner ways to do this, but I’m using this in production and it
works.

Regards,
Gene

===== start of template contents
{ ### Tells user that ticket has been resolved
my $MyName = “Template 28 (Resolved)”;
#$RT::Logger->debug(“$MyName (”. $Transaction->Id . “) entered.”);
my $FromAddress = ‘RT Requests rt@myorg.org’;
my $ContactAddress = ‘real.person@myorg.org’;
my $OwnerName = $Ticket->OwnerObj->RealName;
my $c_content;
my $e_content;
my $have_rmks;
my $remarks;

We won’t include a comment if…

- Last outgoing email content eq last correspond content (this means

that the content was already sent in an e-mail)

- Last correspond attachment headers =~ /^Received/ (this means that

the correspond was an incoming e-mail)

Get last Correspond

my $Transactions = $Ticket->Transactions;
$Transactions->Limit( FIELD => ‘Type’, VALUE => ‘Correspond’ );
$Transactions->OrderByCols (
{ FIELD => ‘Created’, ORDER => ‘DESC’ },
{ FIELD => ‘id’, ORDER => ‘DESC’ },
);
my $CorrespondObj = $Transactions->First;
if ($CorrespondObj && $CorrespondObj->Id) {
$c_content = $CorrespondObj->Content;
chomp $c_content;
$have_rmks = !$CorrespondObj->Attachments->First->GetHeader(‘Received’);
#$RT::Logger->debug(“$MyName: found correspondence: ‘$_content’”) if
$have_rmks;
}

Get last outgoing e-mail

$Transactions = $Ticket->Transactions;
$Transactions->Limit( FIELD => ‘Type’, VALUE => ‘EmailRecord’ );
$Transactions->OrderByCols (
{ FIELD => ‘Created’, ORDER => ‘DESC’ },
{ FIELD => ‘id’, ORDER => ‘DESC’ },
);
my $EmailObj = $Transactions->First;
if ($EmailObj && $EmailObj->Id) {
$e_content = $EmailObj->Content;
chomp $e_content;
if ($c_content) {
$have_rmks = 0 if $e_content eq $c_content;
$have_rmks = 0 if $EmailObj->Id > $CorrespondObj->Id;
}
}

use Mail::Address;
my $Cc = ‘’;
my $Bcc = ‘’;
if ( $have_rmks ) {
my $attachment = $CorrespondObj->Attachments->First;
my @cc_addrs = Mail::Address->parse($attachment->GetHeader(‘RT-Send-Cc’));
my @bcc_addrs =
Mail::Address->parse($attachment->GetHeader(‘RT-Send-Bcc’));
foreach my $addr ( @cc_addrs ) {
$Cc .= $addr->address . ", ";
}
$Cc .= $Ticket->QueueObj->Cc->MemberEmailAddressesAsString;
$Cc =~ s/, $//;

 foreach my $addr ( @bcc_addrs ) {
   $Bcc .= $addr->address . ", ";
 }
 $Bcc .= $Ticket->QueueObj->AdminCc->MemberEmailAddressesAsString;
 $Bcc =~ s/, $//;

}

Set the remarks if applicable

if ($have_rmks) {
$remarks = "
Comments:
$c_content
====================“;
#$RT::Logger->debug(”$MyName: going to send comments: $remarks");
}
my $AddressGroup = “From: $FromAddress”;
$AddressGroup .= “\nCc: $Cc” if $Cc;
$AddressGroup .= “\nBcc: $Bcc” if $Bcc;
$OUT = "$AddressGroup

The ticket that was opened for your request has been resolved by
$OwnerName. If you have any questions about this, you can contact us at
$ContactAddress.
$remarks

Regards,
The IT Staff";

}
===== end of template contents

At 10:42 AM 5/5/2008, Nelson Pereira wrote:

Content-Class: urn:content-classes:message
Content-Type: multipart/related; type=“multipart/alternative”;
boundary=“----_=_NextPart_001_01C8AED7.61321FB3”

Hi,

Wondering how to do this:

When I resolve a ticket, I want RT to send the message I put in the
resolve to the requestor, and not the default “as per our records….”

Nelson Pereira
Senior Network Administrator

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Nelson,

We created our own template and put the following code in it:

#MAKE SURE YOUR TEMPLATE HAS A BLANK LINE AFTER THE “Subject:” LINE!!!

This ticket has been resolved. DO NOT REPLY to this message!
TICKET INFORMATION:
Ticket Queue : {$Ticket->QueueObj->Name}
Ticket Number : {$Ticket->Id}
Ticket Subject: {$Ticket->Subject}
Ticket Description:
{$Ticket->FirstCustomFieldValue(‘Description’)}

Ticket Priority is: {$Ticket->Priority}
Ticket Requestor : {$Ticket->Requestors->UserMembersObj->First->Name}
Ticket Created by: {$Ticket->CreatorObj->Name}
Ticket Created on: {substr($Ticket->Created, 0, 10)}
Ticket Owned by: {$Ticket->OwnerObj->Name}
Development Started on: {substr($Ticket->Started, 0, 10)}
QA Approved on: {$Ticket->FirstCustomFieldValue(‘QA Approval Date’)}
QA Approved by: {$Ticket->FirstCustomFieldValue(‘QA Approver’)}
Migrated on: {substr($Ticket->Resolved, 0, 10)}
Migrated by: {$Ticket->LastUpdatedByObj->Name}
Resolution comment:
{
my $Resolution_Comment;
my $Transactions;
my $CommentObj;

   $Transactions = $Ticket->Transactions;
   $Transactions->Limit( FIELD => 'Type', VALUE => 'Comment' );
   $Transactions->OrderByCols(
       { FIELD => 'Created',  ORDER => 'DESC' },
       { FIELD => 'id',     ORDER => 'DESC' },
       );

   $CommentObj = $Transactions->First;

   if  ($CommentObj && $CommentObj->id)
   {
        $Resolution_Comment = $CommentObj->Content;
   }
   else
   {
        $Resolution_Comment = "No comment."
   }

   return $Resolution_Comment;
  }

To view ticket information, enter URL:

 {$RT::WebURL}Ticket/Display.html?id={$Ticket->id}


Of course, you will certainly not have the same CF's in your tickets 

and we use the “Comment” not the reply to insert into the template. But
I think this will give you an idea on how to do this. Hope this helps.

Kenn
LBNLOn 5/5/2008 10:42 AM, Nelson Pereira wrote:

Hi,

Wondering how to do this:

When I resolve a ticket, I want RT to send the message I put in the
resolve to the requestor, and not the default �as per our records�.�

Nelson Pereira
Senior Network Administrator

Protus IP Solutions Inc.
npereira@protus.com mailto:npereira@protus.com
phone: 613.733.0000 ext.528
MyFax: 613.822.5083
www.myfax.com http://www.myfax.com

Refer your friends and colleagues to MyFax!
Click here for more information.
http://www.myfax.com/referral_program.asp

www.MyFax.com http://www.myfax.com



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

At Monday 5/5/2008 01:42 PM, Nelson Pereira wrote:

Hi,

Wondering how to do this:

When I resolve a ticket, I want RT to send the
message I put in the resolve to the requestor,
and not the default “as per our records….”

Disable the “On resolve notify Requestors” scrip,
and resolve tickets by adding a reply & changing
the status. The Mason code can be changed so that
when you use the “Resolve” link, the “Update
type” is set to Reply rather than Comment.

Steve

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)