[rt-users] Filling Custom Fields from E-mail

Dirk Pape pape-rt at inf.fu-berlin.de
Tue Jun 3 02:48:23 EDT 2003


Hello Jason,

--Am Montag, 2. Juni 2003 11:48 Uhr -0500 schrieb Jason Alexander 
<jason-alexander at uiowa.edu>:

> 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:

On Create

Custom Action prepare:
return(1);

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);
my $id;
my $msg;

#$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");

return(1);

You can strip the debug code from the code.

Explanation:

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 
triples:
(HeaderFieldName, TargetCustomFieldName, substitution code), where the 
substitution code is basicly a s/// command, which converts the found 
header value to the customFieldValue.

Dirk.




More information about the rt-users mailing list