[rt-users] Change ticket subject before first outgoing correspondence.

Michael Mol mikemol at gmail.com
Thu Aug 7 14:29:28 EDT 2014


On Thu, Aug 7, 2014 at 2:00 PM, Michael Mol <mikemol at gmail.com> wrote:

[snip]

> ### Begin snippet
> # Find the message from transactionobj->content
> # Set the subject to the message by using ticketobj->SetSubject
>
> my $body = $self->TransactionObj->Content;
> my @lines = split(m/\n/, $body);
> my $trapID = $lines[0];
> my $message = $lines[2];
>
> $RT::Logger->warn("Setting RT ticket subject: " . "$trapID -- $message");
>
> $self->TicketObj->SetSubject("$trapID -- $message");
> ### End snippet
>
> My last option appears to be to write a template that duplicates the
> above logic in the template itself, which feels dirty, and looks
> worse...

For completeness and google-worthy archives, here's the Template that
works. It's a queue-specific template with the name "Transaction":

### Begin snippet
RT-Attach-Message: yes
Subject:{ my $subject;

  if ( $Ticket->Subject eq "HP Insight Management Agents Trap Alarm" ) {
    my $body = $self->TransactionObj->Content;
    my @lines = split(m/\n/, $body);
    my $trapID = $lines[0];
    my $message = $lines[2];

    $subject = "$trapID -- $message";
  } else {
    $subject = $Ticket->Subject;
  }
  $subject; # Return the subject out of the code block, and thus into
the template body.
}

<URL: {RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id} >

{$Transaction->Content()}
### End snippet

It needs to be combined with the above Scrip for full effectiveness,
if you want the ticket subject to be reflected in the email.

I'm tempted to drill down deeper and parse out $trapID and make it
it's own header; the content is always something like "Trap-ID=3047"
or "Trap-ID=11020", and I could make the template add a header of
"X-Trap-ID: 3047", but that would serve no useful purpose at this
time. OTOH, if I created more custom fields for the queue, I could
dump each of those individually into headers. But, again, not
immediately useful, so not doing that, regardless of how cool it'd be.
Maybe after I implement sieve on our mailservers...


-- 
:wq



More information about the rt-users mailing list