Hey everybody,
I’ve been using RT for a number of years in various jobs, and it’s a
great tool. I’m trying to deploy it now for a somewhat novel use case
(managing law review submissions), and I need some help with scrip
voodoo. I’m not much of a perl guy, but I can kind of follow along.
We get dozens of submissions per day via email sent from an electronic
service. The emails we get all come with headers from the service
itself. The bodies of the messages are consistently formatted, and
contain lines with information about each article, e.g.
Title: Undue Influence and the Rise of Greedy Lawyers
Author: John Q. Blowhard, Esq.
You may contact the author at: blowhard@ivyleague.edu
I’d like to have a scrip that will use regular expressions to extract
the above information, and update the ticket appropriately. For
example, I’d like the “Title” to become the subject of the ticket and
the “Author” to become the requestor, with the email address set
appropriately.
Is this something that I can do with a scrip? Can anyone point me to
some resources on how to extract info from the body of a ticket using
regular expressions, and use that data to update ticket fields?
Many thanks!
-C-
Ok, yes… ExtractCustomValues appears to be capable of doing what I want.
I’m unclear on what I can put in the “script” field of the template.
For example, here’s what I’ve done…
- Created template in my queue containing the following:
||Body|^Title:\s*(.*)|$self->TransactionObj->Set( Subject => $_ )||
-
Created scrip in my queue: on create, extract custom values, my new
template.
-
Send test messages; subject does not change, nothing in syslog.
I have a feeling that the “script” field in my template isn’t right.
What can I put in this field???
Appreciate any pointers in the right direction…
-C-
Hi Chris,
I’m not familiar with the extension, but a couple of observations might
help (or not).
-
With other templates, you would use “$Transaction->” instead of
“$self->TransactionObj->”. I don’t know whether this is true for this
extension. The “$self” notation generally applies to scrips.
-
It looks like you’re setting the subject of the transaction rather than
the ticket. I’d try “$Ticket->Set(Subject=>$)" assuming that the Set
syntax is correct. Or "$self->TicketObj->Set(Subject=>$)” if I’m off-base
with observation #1.
Just some place to start looking.
Regards,
Gene
At 02:06 PM 4/13/2008, Chris Haumesser wrote:
Ok, yes… ExtractCustomValues appears to be capable of doing what I want.
I’m unclear on what I can put in the “script” field of the template.
For example, here’s what I’ve done…
- Created template in my queue containing the following:
||Body|^Title:\s*(.*)|$self->TransactionObj->Set( Subject => $_ )||
-
Created scrip in my queue: on create, extract custom values, my new
template.
-
Send test messages; subject does not change, nothing in syslog.
I have a feeling that the “script” field in my template isn’t right.
What can I put in this field???
Appreciate any pointers in the right direction…
-C-
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
Gene LeDuc, GSEC
Security Analyst
San Diego State University
I think I’ve got this one licked.
I’ll be doing a full write-up of my project at www.awry.ws in a few days.
- With other templates, you would use “$Transaction->” instead of
“$self->TransactionObj->”. I don’t know whether this is true for this
extension. The “$self” notation generally applies to scrips.
Yes, as it turns out, ExtractCustomFieldValues.pm defines $Transaction
and $Ticket for me thusly:
my $Transaction = $self->TransactionObj;
my $Ticket = $self->TicketObj;
so one can use simply $Transaction or $Ticket.
- It looks like you’re setting the subject of the transaction rather
than the ticket. I’d try “$Ticket->Set(Subject=>$)" assuming that the
Set syntax is correct. Or "$self->TicketObj->Set(Subject=>$)” if I’m
off-base with observation #1.
Yup, figured that out, too. The final magic for the template ended up
being:
|body|^Title:\s*(.*)$|$Ticket->SetSubject($_);|
I also had a hell of a time just getting ExtractCustomFieldValues to
operate at all on the message body, until I realized that the “newest
version always here” link on
http://wiki.bestpractical.com/view/ExtractCustomFieldValues doesn’t
point to the newest version after all. My progress accelerated
considerably once I got the right code!
Still, the ExtractCustomFieldValues.pm only looks at the first
attachment to a ticket, so it doesn’t work on multipart messages. I had
to rework the module a bit to have it iterate over all attachments
instead. Modified pm is here: http://tinyurl.com/3kh37e (untested - YMMV).
Learning perl is, uh… fun.
-C-