[rt-users] Parse initial e-mail
Andy Harrison
aharrison at gmail.com
Fri Feb 25 22:35:36 EST 2005
On Fri, 25 Feb 2005 15:48:02 -0500, Cornell Green
<cornellgreen at gmail.com> wrote:
> I am attempting to parse the initial email that initiates a ticket.
>
> I have created a custom scrip. This part I have working:
>
> Description: $Descrip_name (not important)
> Condition: User Defined
> Action: Notify CCs as Comment
> Template: $Templ_name (again, not important; but the template itself
> included below)
> Stage: TransactionCreate
>
> Custom Condition:
> if($self->TicketObj->Status eq 'new' and
> $self->TransactionObj->CreatorObj->EmailAddress() =~ /$match_pattern/
> ){
> return 1;
> }
>
> ...for privacy I have, obviously, substituted "$match_pattern" for the
> *actual* pattern the condition contains...
>
> Custom action preparation code:
>
> my $self = $Transaction;
> my @lines = split(/\n/,$self->TicketObj->Transactions->First->Attachments->First->Content());
>
> foreach my $this_line ( @lines ){
> if ( $this_line =~ /Caller\'s Phone Number:/ ){;
> my ($caller) = ($this_line);
> return $caller;
> } else {
> next;
> }
> }
> 1;
>
> Custom action cleanup code:
>
> 1;
>
> The custom scrip this triggers:
>
> Subject: AutoReply: Toll-free support call
>
> A call from {$caller} has created [{$rtname} #{$Ticket->id()}] in the
> Trouble Ticket system.
>
> Unfortunately, the output I receive is:
>
> A call from has created [garagenet.com #NNN] in the Trouble Ticket system.
>
> Clearly, although I have figured out how to create the correct trigger
> condition, I have *not* determined how to parse the initial email.
> Does anyone have any idea what I'm doing wrong? Is there any tutorial
> on the RT Ticket/Transaction object schema, as it relates to accessing
> aspects of it in a custom scrip?
First, using Status eq 'new' for your condition probably isn't the thing to do.
Use something like:
return undef unless ($self->TransactionObj->Type eq "Create");
Secondly, you have no code in the template to give $caller any sort of
value. I think you can rip that whole custom action out and if you
use the same code to fetch the value for $caller right in the
template, it would probably work.
--
Andy Harrison
More information about the rt-users
mailing list