Auto-assign Tickets based on the day of the week
This article explains how to create a Scrip with a user-defined action to automatically assign tickets as they are created in your queue to different individuals based on the day of the week. This can come in handy if you have different users assigned to keep an eye on your queue traffic for different weekdays.
Context
- Request Tracker (RT) on help.mit.edu
- Queue Administrators with the ability to write basic Perl code
Answer
Navigate to your queue's "Scrips" administration page
- Go to the Tools menu in RT and navigate to Configuration, then Queues, then Select
- Click on the name of your queue in the list of queues
- On the Queue Basics administration page go to the Scrips tab and select Create to open a New Scrip form
Fill out the New Scrip form to create your user Scrip
Fill out the form using the list below as a guide. You will of course want to substitute your own usernames for the ticket owners you want to set for the different days of the week.
- Description: On Create assign a ticket Owner based on day of week
- Condition: On Create
- Action: User Defined
- Template: Global Template: Blank
- Stage: TransactionCreate
Then fill out the Custom Action Preparation Code and Custom Action Cleanup Code boxes. Leave the Custom Condition box empty.
- Custom Action Preparation Code:
return 1;
- Custom Action Cleanup Code:
my %owners = ( 'Monday' => 'othomas', 'Tuesday' => 'joeuser', 'Wednesday' => 'othomas', 'Thursday' => 'joeuser', 'Friday' => 'othomas', 'Saturday' => 'joeuser', 'Sunday' => 'othomas' ); my @weekdays = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); my ($status, $msg) = $self->TicketObj->SetOwner( $owners{$weekdays[DateTime->now(time_zone => 'America/New_York')->dow - 1]} ); unless( $status ) { $RT::Logger->error( "Unable to assign ticket #" . $self->TicketObj->id . " to user " . $owners{$weekdays[DateTime->now->dow - 1]} . ": $msg" ); return undef; }
Save and test your work
- After filling out the form as above, click the Create button to save and apply your Scrip
If you get an error at this point, there is a problem with your Perl code in one of the two Custom Action boxes. Review them carefully, and contact tooltime@mit.edu if you get stuck. - Test your scrip by creating test tickets in your queue over the course of the week and verifying that they are auto-assigned to the correct individuals.