[rt-users] ExtractCustomFieldValues, insert fixed value when match
Stefan Stefanov
ststefanov at gmail.com
Tue May 8 05:01:51 EDT 2012
Thank you!
I made this way:
Scrip:
Condition: On Create
Action: User Defined
Template: GlobalTemplate: Blank
Stage: TransactionCreate
Custom action preparation code:
my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $cf_obj = RT::CustomField->new($RT::SystemUser);
my $cf_value;
# set some other default values
$cf_obj->LoadByName(Name=>"CF1");
$cf_value="mail";
$ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$cf_value,
RecordTransaction=>0);
$cf_obj->LoadByName(Name=>"CF2");
$cf_value="Outstanding";
$ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$cf_value,
RecordTransaction=>0);
# set value by requestor address
my $ticketRequestor = lc($ticket->RequestorAddresses);
$ticketRequestor =~ /(^.+)@([^\.].*\.[a-z]{2,}$)/;
#if ( $1 =~ /^username$/m ) {
#$self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'ONE' );
#}
if ( $2 =~ /^domain1.local$/m ) {
$self->TicketObj->AddCustomFieldValue( Field => 'DOMAIN', Value => 'Domain1' );
}
return 1;
Next ExtractCustomFieldValues extension is started and custom field
values are set according incoming mail.
But my question was:
Is it possible to do same thing as last one using _only_ template for
ExtractCustomFieldValues extension?
(for example some regex returning value 'Domain1' if incoming mail
From: field is .*@domain1.local)
Thanks again to all for help!
--
Stefan Stefanov
More information about the rt-users
mailing list