Resolve ticket and include message body in ticket

Hi,

I’m quite new to RT and wondering how to do the following.

I need to resolve a ticket when an email is sent to the queue resolve
address, for example, myqueue-resolve@domain.com. This is fine, and I
have managed to do this by adding a new ‘rt-mailgate’ command with an
action of ‘resolve’ to my /etc/aliases file.

However, the person sending this email will include some text describing
the reason for resolving the ticket, among other things, and I would
like this text to be added to the ticket when it is resolved and I can’t
find a way to do this.

I tried creating a custom scrip with a custom template of
${Transaction->Content()} or something like that, but it didn’t work.

Any help appreciated.

Thanks,
Khusro

Khusro,

You do not need a Custom Field to do this. The transaction content is
available at “Resolve” time via a code in your template. We do this. We
created our own “Resolve” template and deleted the delivered one. This
is our code:

This ticket has been resolved. DO NOT REPLY to this message!
TICKET INFORMATION:
Queue : {$Ticket->QueueObj->Name}
Number : {$Ticket->Id}
Priority is: {$Ticket->Priority}
Requestor : {$Ticket->Requestors->UserMembersObj->First->Name}
Created by: {$Ticket->CreatorObj->Name}
Created on: {substr($Ticket->Created, 0, 10)}
Owned by: {$Ticket->OwnerObj->Name}
Development Started on: {substr($Ticket->Started, 0, 10)}
Description of Issue:
{$Ticket->FirstCustomFieldValue(‘Description’)}

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}

Hope this helps.

Kenn
LBNLOn 7/7/2009 2:13 AM, Khusro Jaleel wrote:

Hi,

I’m quite new to RT and wondering how to do the following.

I need to resolve a ticket when an email is sent to the queue resolve
address, for example, myqueue-resolve@domain.com. This is fine, and I
have managed to do this by adding a new ‘rt-mailgate’ command with an
action of ‘resolve’ to my /etc/aliases file.

However, the person sending this email will include some text describing
the reason for resolving the ticket, among other things, and I would
like this text to be added to the ticket when it is resolved and I can’t
find a way to do this.

I tried creating a custom scrip with a custom template of
${Transaction->Content()} or something like that, but it didn’t work.

Any help appreciated.

Thanks,
Khusro


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

Ken Crocker wrote:

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;
}

I tried entering just the above into a new Template and then created a
Scrip that would run “On Resolve”. I told the scrip to use this new
template, however, all I got in the end was

Resolution Comment:
No comment

I definitely entered a few words into the body of the resolved email
message. So clearly I’ve missed something off? I have a feeling it
should not be $Transactions->First? Wouldn’t that give you just the
first Transaction when we are looking for the last one?

The scrip I’m using is set as “On Resolve, Notify AdminCCs as Comment,
Template MyNewResolvedTemplate, Stage TransactionCreate”.

Khusro,

The “Notify AdminCcs as Comment” won’t send out an email. At least that
is my understanding. So, if I’m right, some other scrip is sending out
the email and therefore your new template is probably NOT being used. Of
course, if I’m wrong about the “as Comment”, then ignore my response.

Kenn
LBNLOn 7/7/2009 9:58 AM, Khusro Jaleel wrote:

Ken Crocker wrote:

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;
}

I tried entering just the above into a new Template and then created a
Scrip that would run “On Resolve”. I told the scrip to use this new
template, however, all I got in the end was


Resolution Comment:
No comment

I definitely entered a few words into the body of the resolved email
message. So clearly I’ve missed something off? I have a feeling it
should not be $Transactions->First? Wouldn’t that give you just the
first Transaction when we are looking for the last one?

The scrip I’m using is set as “On Resolve, Notify AdminCCs as Comment,
Template MyNewResolvedTemplate, Stage TransactionCreate”.

Ken Crocker wrote:

Khusro,

The “Notify AdminCcs as Comment” won’t send out an email. At least that
is my understanding. So, if I’m right, some other scrip is sending out
the email and therefore your new template is probably NOT being used. Of

Thanks for the quick response, Ken. I have actually gone into the global
settings and set ‘Stage = Disabled’ globally for the On Resolve script,
and since we have other queues on this box, we know that usually on
Resolve, nothing gets sent out.

However, I need to enable it on this one special queue, and I know that
my template is actually working because I get the text:

Resolution Comment:
No Comment

I don’t have any such text anywhere else in the system, only this queue.
So I know the scrip and template are working, but just not seeing the
response I typed in for some reason. The emails to the AdminCCs are
being sent out, just with “No comment” in the body instead of my text.

Khusro,

Must be your code. Can you send it?

Kenn
LBNLOn 7/7/2009 10:48 AM, Khusro Jaleel wrote:

Ken Crocker wrote:

Khusro,

The “Notify AdminCcs as Comment” won’t send out an email. At least that
is my understanding. So, if I’m right, some other scrip is sending out
the email and therefore your new template is probably NOT being used. Of

Thanks for the quick response, Ken. I have actually gone into the global
settings and set ‘Stage = Disabled’ globally for the On Resolve script,
and since we have other queues on this box, we know that usually on
Resolve, nothing gets sent out.

However, I need to enable it on this one special queue, and I know that
my template is actually working because I get the text:

Resolution Comment:
No Comment

I don’t have any such text anywhere else in the system, only this queue.
So I know the scrip and template are working, but just not seeing the
response I typed in for some reason. The emails to the AdminCCs are
being sent out, just with “No comment” in the body instead of my text.


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

Ken Crocker wrote:

Khusro,

Must be your code. Can you send it?

It’s just the following, in a new template:

According to our records, your request has been resolved. If you have
any further questions, please respond to this message.
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;
 }

Khusro,

My mistake. I thought you had said you already had code similar to what
I sent you. What you just sent looks a lot like my code. At this point,
I have no idea why your not getting a comment as ours works quite well.
Unless, of course, we are missing the obvious, which is “Is someone
actually entering a comment when they Resolve the ticket”? Sorry I can’t
help.

Kenn
LBNLOn 7/7/2009 11:06 AM, Khusro Jaleel wrote:

Ken Crocker wrote:

Khusro,

Must be your code. Can you send it?

It’s just the following, in a new template:

===========================================================================================

According to our records, your request has been resolved. If you have
any further questions, please respond to this message.

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;
}

===========================================================================================

Khusro,

My mistake. I thought you had said you already had code similar to what
I sent you. What you just sent looks a lot like my code. At this point,
I have no idea why your not getting a comment as ours works quite well.
Unless, of course, we are missing the obvious, which is “Is someone
actually entering a comment when they Resolve the ticket”? Sorry I can’t
help.

Many thanks for your help, Ken. I’ll keep trying…