[rt-users] automatically set due date and priority based on customfield

Roedel, Mark MarkRoedel at letu.edu
Fri Dec 16 17:55:35 EST 2005

Here's the scrip we've got on our production server that sets both
priority and due dates on a ticket based on our 'Urgency' custom field.
It also uses the Business::Hours perl library to ensure that our
shorter-term tickets come due when we're actually here.

Custom condition:
if (($self->TransactionObj->Type eq "CustomField") and
($self->TransactionObj->Field eq "13")) {
} else {

Custom action cleanup:
my $ticket = $self->TicketObj;
my $CFName = 'Urgency';
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new ($QueueObj->CurrentUser);
my $duedate = RT::Date->new($RT::SystemUser);
my $bus_hours_duetime = time;

use Business::Hours;
my $hours = Business::Hours->new();
my $now = time;

$CFObj->LoadByNameAndQueue(Name=>$CFName, Queue=>$QueueObj->id);
unless ($CFObj->id) {
  $RT::Logger->warning ("$CFName doesn't exist in Queue " .
  return undef;

my $urgencyvalue = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
if ($urgencyvalue eq 'Emergency') {
  $bus_hours_duetime = $hours->add_seconds ($now, 14400);
  $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
} elsif ($urgencyvalue eq 'Urgent') {
  $bus_hours_duetime = $hours->add_seconds ($now, 32400);
  $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
} elsif ($urgencyvalue eq 'Time-Sensitive') {
  $bus_hours_duetime = $hours->add_seconds ($now, 97200);
  $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
} elsif ($urgencyvalue eq 'High') {
  $duedate->Set(Format=>'unknown', Value=>'15 days');
} elsif ($urgencyvalue eq 'Medium') {
  $duedate->Set(Format=>'unknown', Value=>'3 months');
} elsif ($urgencyvalue eq 'Low') {
  $duedate->Set(Format=>'unknown', Value=>'6 months');
} elsif ($urgencyvalue eq 'Very Low') {
  $duedate->Set(Format=>'unknown', Value=>'1 year');
} else {

Mark Roedel
Web Programmer / Analyst
LeTourneau University

-----Original Message-----
From: rt-users-bounces at lists.bestpractical.com
[mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Matt
Sent: Friday, December 16, 2005 1:37 PM
To: rt-users at lists.bestpractical.com
Subject: [rt-users] automatically set due date and priority based on


I'd like to automatically set the due date and priority of new tickets 
based on a users selection of the custom field 'severity'. The creation
the custom field 'severity' was the easy part. My understanding is that 
the automatic setting of due date and priority based on this custom
can be accomplished with a scrip. Has anyone done anything similar to 

More information about the rt-users mailing list