[rt-users] RT changing Status to Open from Resolved when sending Reply or Comment

Gene LeDuc gleduc at mail.sdsu.edu
Mon Apr 21 12:56:57 EDT 2008


Hi John,

I ran into the same "resolved but no comments sent" issue.  I found that 
the stuff you type into the message box gets treated as a separate 
correspond transaction first, then the ticket gets resolved.  So I had my 
Resolved template look for an unsent correspondence and, if found, attach 
it to the resolved message.  I determine whether or not it has already been 
sent by comparing the last correspond with the last outgoing e-mail - if 
they're different then I include the last correspond content.  I have all 
default scrips disabled, so the correspond transaction doesn't send 
anything on its own.

Here's the guts of the template if you're interested.  It's probably much 
more complicated than it needs to be, but I was still pretty new at RT.  It 
works, so I won't be changing it anytime soon.

{ ### Tells user that ticket has been resolved
   my $MyName = "Template DNS:28 (Resolved)";
$RT::Logger->debug("$MyName (". $Transaction->Id . ") entered.");
   my $FromAddress = 'My Org <myorg at example.com>';
   my $ContactAddress = 'rtguy at example.com';
   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;

   ### Ignore last correspond if it has Received headers
   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 there's a previous e-mail and it's the same as the previous 
correspond, ignore it
   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
Subject: Action completed

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

Regards,
The ITSO Staff";

}


At 09:23 AM 4/21/2008, John  BORIS wrote:
>I remember this being a discussion thread a while back but searching the
>archives I couldn't find it. I found one thread from 2003 but it didn't
>address a resolution.
>
>I resolved a ticket and then noticed my auto reply to the requestor
>didn't include my resolution information. So I went back into RT and
>clicked reply to send a reply to the requester from RT. When I looked at
>the History I saw the Ticket was now Open and I had to reset it to
>Resolved. When I sent the reply there is a transaction that shows Ticket
>Status changing from Resolved to Open.
>
>
>Is there a fix for this? Or is this a correct way for this to work?
>
>TIA
>
>John J. Boris, Sr.
>JEN-A-SyS Administrator
>Archdiocese of Philadelphia
>
>"Remember! That light at the end of the tunnel
>Just might be the headlight of an oncoming train!"
>_______________________________________________
>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
>Community help: http://wiki.bestpractical.com
>Commercial support: sales at bestpractical.com
>
>
>Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>Buy a copy at http://rtbook.bestpractical.com


-- 
Gene LeDuc, GSEC
Security Analyst
San Diego State University 




More information about the rt-users mailing list