Email transaction content to requestor when ticket status is resolved

Hello, I am new to RT development and I have one issue from the following flow which I have yet to find a solution for it. Below is the basic flow:

  1. Requestor send email to RT with a predefined table format in the email.
  2. RT will automatically create a new ticket from the email.
  3. Owner will be assigned (manual or auto).
  4. RT will send notification email to the owner.
  5. Owner will reply via email to RT with content “status: taken” (Extension: CommandByMail) to confirm that he has read the ticket.
  6. Once the issue is resolved, owner will reply via email to RT with content “status: resolved” and also fill up some values (arrival time, departure time…etc) in the table which was originally send by the requestor.

The requestor only expect email from RT after the issue is resolved, and the email must include those information (arrival time, departure time…etc) filled up by the ticket owner in the email. First I tried to use the Condition → On Resolve, Action → Notify Requestor, Template → Resolve, only after that I noticed that I cannot use ({$Transaction->Content( Type => “text/html”)}) for on resolve as it will always return empty content. Then I tried Condition → On Correspond where ({$Transaction->Content( Type => “text/html”)}) will show in the content, but the requestor will get email for each correspond which is not they want. Is there a way to only trigger the Condition → On correspond after the ticket status changed to resolved. Or is there a better workaround for this? Thank you!

Not quite sure why you can’t use the On Resolve predefined actions but assuming you can’t why not use either a On Status Change action and then check that the status is “resolved” in your template, or use a custom condition and check the ticket status (and maybe that all your required custom data is there)?

Hi GreenJimll, thanks for your reply. The reason why I can’t use the On resolve or check the value for On Status is because I need to include the $Transaction->Content in my template to reply to the requestor. For the above conditions, the Transaction content will always be empty where the requestor will receive “This transaction appears to have no content” in the reply to them.

Instead of having your team member reply to the ticket to set status and other values, can they comment? That way the requestor won’t get a on reply email

But don’t forget you can use the whole RT Perl API in a Perl based template, so you can get all of the transactions associated with a ticket, and look just for the ones you want.

Basically we need to include the last comment in the email of the team member who close the ticket via email command to the requestor, i.e when they reply with “Status: resolved”.

We used this {$Transaction->Content( Type => “text/html”)} when the ticket status changed from open → resolved but it always show “This transaction appears to have no content” in the email to the requestor.

I tried this “TransactionBatchStage - Request Tracker Wiki”, but it only works once. The log shows “TransactionBatch stage is disabled, fallback to last comment. Turn on TransactionBatch stages for accurate results” Not sure how to enable it in RT5. Any idea?

As I said, you can use the RT Perl API to get all the Transactions in your template and then decide what to send, if anything (if you return an empty string from the template northing gets emailed). You can get transactions in a template using something like this (off the top of my head - I’ve not tested it but done similar in the past):

{
    my $out = '';

    # Get all the transactions for this ticket, in reverse chronological order.
    my $txns = $TicketObj->Transactions();
    $txns->OrderBy(
        { FIELD => 'Created', ORDER => 'DESC' },
        { FIELD => 'id', ORDER => 'DESC' },
      );
    my $wantedTransaction;
    while(my $thisTransaction = $txns->Next) {
         # Spot the transaction you want. In this case the first comment
         # we hit going backwards from the most recent transaction.
         if($thisTransaction->Type() eq 'Comment') {
             $wantedTransaction = $thisTransaction;
             last;
        }
    }
    # If we found a transaction, update the template output to
    # whatever it is you want to mail out.
    if($wantedTransaction) {
        $out = 'Set this to whatever you want your template to output.';
    }
    $out;
}

Hi GreenJimll, thanks for your suggestion. I shall try it out and get back to you. Meanwhile, I am trying with the On correspond action instead of using On Status Change or On Resolve whereby I am able to get the Transaction content under On correspond action. But I would still prefer to do it under On Status change or On Resolve action. Will get myself familiarize with the Perl API and try out your suggestion.