Set an RT Custom Field automatically on ticket creation
Context
- Request Tracker (RT) on help.mit.edu
- Request Tracker queue administrators
Answer
This article explains how to set a Custom Field attached to your queue to a default value whenever a ticket is created. There are many reasons you might want to do this. A common use case is a flag attached to your tickets that is almost always set to the same value, but occasionally needs to be set to something else.
For example, you might have a "Send Survey" custom field that determines whether a customer receives a follow-up satisfaction survey or not. This field is almost always set to "Yes", but you may want to set it to "No" occasionally to prevent a survey from being done. We will use this example to illustrate the procedure below.
Make sure the custom field exists and has been attached to a queue for which you are the queue administrator; for more information on how to do this please see Creating and managing Request Tracker Custom Fields.
Next, create a user-defined Scrip for your queue that sets the field whenever a ticket is created. If you do not see the "User Defined" text areas, you may not have the necessary permissions to create custom Scrips for your queue.
- Navigate to Tools > Configuration > Queues > Select and click on your queue in the list of queues
- Navigate to the Scrips tab, hover over it, and click on Create
- Enter a new Scrip with the following settings:
- Description: On Create set Send Survey custom field to Yes (or something similar)
- Condition: On Create
- Action: User Defined
- Template: Global template: Blank
- Stage: TransactionCreate (this is the default)
- Custom condition: (leave blank)
- Custom action preparation code:
return 1;
- Custom action cleanup code:
my $CFName = 'Send Survey'; my $DefaultValue = 'Yes'; unless( $self->TicketObj->FirstCustomFieldValue( $CFName ) eq $DefaultValue ) { my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue( Field => $CFName, Value => $DefaultValue, RecordTransaction => 1 ); } return 1;
- Click the Create button to save your custom Scrip
Be sure to replace "Send Survey" and "Yes" in the above example with the appropriate values for your queue.