Access Keys:
Skip to content (Access Key - 0)

Q: How do I set a Custom Field on ticket creation based on To address?


  • Request Tracker (RT) on
  • Request Tracker queue administrators – you have to be one to follow these instructions


All messages received by the same address on the RT server will create tickets in the same queue, even if the "To" addresses are different. For example, if the Tooltime queue's main email address "" but you also have a alias, "", both will create tickets in the Tooltime queue. Sometimes you may want an indication of which address the message was sent to, to automatically categorize or assign it. This can be done with a custom Scrip which examines the header of the incoming message and takes action based on the "To" line. The below example illustrates how to set a custom field based on the "To" address in the header.

Example: Set Custom Field Value Based On To Address


Create a custom scrip that fires when a ticket is created via email

1 Navigate to Tools > Configuration > Queues > Select, find your queue in the list and click on it to go to its configuration screens
2 Navigate to the Scrips tab menu and select Create to create a new Scrip
3 Fill out the create screen as follows:
  • Description: On Email Create Set Custom Field Based On To Address
  • Condition: On Email Create
  • Action: User Defined
  • Template: Blank
  • Stage: TransactionCreate
4 Fill out the "Custom condition", "Custom action preparation code", and "Custom action cleanup code" code boxes as follows. If you do not see those three boxes for entering custom code, you may not have the necessary permissions to write Perl code on the system. Contact your queue admin, or if you need this access.
Custom condition

Custom action preparation code
return 1;
Custom action cleanup code
my $CFName = 'Category';
my $CFValue = 'New Queue';

foreach my $h (qw(To Cc)) {
    my $header = $self->TransactionObj->Attachments->First->GetHeader($h);
    my @addr = Mail::Address->parse($header);
    foreach my $addrobj (@addr) {
        my $addr = lc $RT::Nobody->UserObj->CanonicalizeEmailAddress($addrobj->address);
        if ( $addr =~ /tooltime-newqueue\ ) {
            unless( $self->TicketObj->FirstCustomFieldValue( $CFName ) eq $CFValue ) {
                my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue(
                    Field => $CFName,
                    Value => $CFValue,
                    RecordTransaction => 1 );
            return 1;
return 1;
5 Double-check your code and click the Create button to save your changes

That's it! Test your new Scrip by sending email to your queue at both addresses, and verify that the custom field is set on creation.

Important Reminders

  • Remember to substitute your own queue name, custom field name, custom field value, and email address!
  • Test your scrip before you advertise the functionality to your team; scrips work independently, so if there is an error in your scrip, this feature will not work but it should not impact the general operation of your queue
  • Consider a slighly more complicated Perl conditional such as if-elsif-else if you need to check for multiple email addresses and set multiple custom field values

IS&T Contributions

Documentation and information provided by IS&T staff members

Last Modified:

July 28, 2021

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
rt rt Delete
rt4 rt4 Delete
request_tracker request_tracker Delete
scrip scrip Delete
c-rt4 c-rt4 Delete
routing routing Delete
c-rt-queue-admin c-rt-queue-admin Delete
c-rt-queue-admin-custom c-rt-queue-admin-custom Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
This product/service is:
Easy to use
Difficult to use

This article is:
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki