Help with ExtractCustomFieldValues

I have the following set up for ExtractCustomFieldValues, but it is not
populating my ‘Server’ custom field. Any ideas are much appreciated.

E-mail body:

test
Host: helios
foo

I have tried:
Server|Body|Host:\s(\w+).||
and
Server|Body|Host:(.
)||
in my template. Neither match.

My ExtractCustomFieldValues seems ok, because

Server|Subject|.*||

works ok for populating my ‘Server’ custom field with the contents of
the subject line.

Have I just broken the regular expression? What is going on?
Thanks,
Ryan Fox

Description: ExtractServerNameFromNagios
Condition: On Create
Action: Extract Custom Field Values
Template: CustomFieldServerNagiosExtract
Stage: TransactionCreate

rfox.vcf (309 Bytes)

Hello,

do you have a formatted mail body (html, rich text)? Then your regex might
not match.

Regards,
Dirk.–Am 10. Januar 2006 09:59:16 -0500 schrieb Ryan Fox rfox@findlay.edu:

I have the following set up for ExtractCustomFieldValues, but it is not
populating my ‘Server’ custom field. Any ideas are much appreciated.

E-mail body:

test
Host: helios
foo

I have tried:
Server|Body|Host:\s(\w+).||
and
Server|Body|Host:(.
)||
in my template. Neither match.

My ExtractCustomFieldValues seems ok, because

Server|Subject|.*||

works ok for populating my ‘Server’ custom field with the contents of the
subject line.

Have I just broken the regular expression? What is going on?

Dr. Dirk Pape (Projektleitung Campus Management)
Fachbereich Mathematik und Informatik der FU Berlin
Grunewaldstr. 34a, 12165 Berlin
Tel. +49 (30) 838 75143, Fax. +49 (30) 838 54654

Dirk Pape wrote:

Hello,

do you have a formatted mail body (html, rich text)? Then your regex
might not match.

Thank you. That is what it was, but not in the way I expected.

The body of the message was plain text, but I had a vcard attached.
When I configured my mail client to not send the vcard, the
ExtractCustomFieldValues worked fine.

So it seems as though in a multipart message, the text/plain part does
not get parsed by ExtractCustomFieldValues.
My question now is, is there an easy way to make that happen?

Thanks again,
Ryan

Attached Message (1.05 KB)

Attached Message (373 Bytes)

Ryan Fox <rfox findlay.edu> wrote on 2006-01-10:

So it seems as though in a multipart message, the text/plain part does
not get parsed by ExtractCustomFieldValues.
My question now is, is there an easy way to make that happen?

I’m running into this same problem. ExtractCustomFieldValues is working great on
simple plaintext mail. But as soon as I add an attachment, it stops working.
It’s essential that I get this fixed, and my perl is sorely lacking. I think
the problem is around line 22 of ExtractCustomFieldValues.pm:

my $FirstAttachment = $Transaction->Attachments->First;
unless ( $FirstAttachment ) { return 1; }

then later, around line 46:

my $match = FindMatch( Field           => $InspectField,
                   Match           => $MatchString,
                   FirstAttachment => $FirstAttachment );

The full perl module can be found at lib/RT/Action/ExtractCustomFieldValues.pm - metacpan.org .

At any rate, it seems to me that the module is only checking the “first
attachment” to the ticket (same as the first mimepart? which equals just the
headers on a multipart message?).

How can I easily work around this? I tried setting

my $FirstAttachment = $Transaction->Attachments->Second;

but that did not work.

Any help much appreciated…

-C-

Chris Haumesser <ch awry.ws> writes:

Ryan Fox <rfox findlay.edu> wrote on 2006-01-10:

So it seems as though in a multipart message, the text/plain part does
not get parsed by ExtractCustomFieldValues.
My question now is, is there an easy way to make that happen?

At any rate, it seems to me that the module is only checking the “first
attachment” to the ticket (same as the first mimepart? which equals just the
headers on a multipart message?).

I fixed this by modifying the module to iterate over all attachments, instead of
just matching against the first one. My modified ExtractCustomFieldValues.pm
can be found at http://tinyurl.com/3kh37e. Not extensively tested, so use at
your own risk.

-C-