–Am Montag, 2. Juni 2003 11:48 Uhr -0500 schrieb Jason Alexander
We have setup RT3 with a few custom fields. I would like to fill some of
those fields from the E-mails that we are injecting into the system.
What would be the best way to do this.
I have set up a scrip with the following settings as a proof of concept
(Please see the explanation below!). I will develop this further soon:
Custom Action prepare:
Custom Action cleanup:
my $Ticket = $self->TicketObj;
my $Transaction = $self->TransactionObj;
my $mailer = $Transaction->Attachments->First->GetHeader(‘X-Mailer’);
my $cf = new RT::CustomField($RT::SystemUser);
#$RT::Logger->debug(“load cf mailer”);
($id,$msg) = $cf->LoadByNameAndQueue (Name=>‘mailer’, Queue=>0);
#$RT::Logger->debug(“load cf done: $id $msg”);
$RT::Logger->debug(“add cf mailer ($mailer)”);
($id,$msg) = $Ticket->AddCustomFieldValue (Field => $cf, Value => $mailer);
$RT::Logger->debug(“add cf done: $id $msg”);
You can strip the debug code from the code.
I decided to use headers of the email to transport structured data. We will
later provide a Webform to compose a email and send it to a RT-System. All
structured data will be coded in X-Headers and unstructured data goes into
the mail body.
So the given scrip extracts the value of the “X-Mailer”-Header into a
custom field which must exists globally. Any other header will be good,
too. You can even modify it, by grabbing keywords out of the body.
In future I will make this cistomizable by a template, which consists of
(HeaderFieldName, TargetCustomFieldName, substitution code), where the
substitution code is basicly a s/// command, which converts the found
header value to the customFieldValue.