We have an "Urgency" custom field in one of our queues, and I wrote a couple of 
scrips to set the ticket due date and starting and ending priorities based on 
that field's value.  (One scrip fires on ticket creation, and one fires on a 
change to the custom field's value.)

The scrip configuration for the ticket creation one looks like:

Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate
Custom Action Preparation Code:
        Return (1);
Custom Action Cleanup Code
        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 " . 
$QueueObj->Name);
          return undef;
        }
        
        my $urgencyvalue = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
        if ($urgencyvalue eq 'Emergency') {
          $self->TicketObj->SetPriority('100');
          $self->TicketObj->SetFinalPriority('100');
          $bus_hours_duetime = $hours->add_seconds ($now, 14400);
          $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
          $self->TicketObj->SetDue($duedate->ISO);
        } elsif ($urgencyvalue eq 'Urgent') {
          $self->TicketObj->SetPriority('90');
          $self->TicketObj->SetFinalPriority('99');
          $bus_hours_duetime = $hours->add_seconds ($now, 32400);
          $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
          $self->TicketObj->SetDue($duedate->ISO);
        } elsif ($urgencyvalue eq 'Time-Sensitive') {
          $self->TicketObj->SetPriority('89');
          $self->TicketObj->SetFinalPriority('89');
          $bus_hours_duetime = $hours->add_seconds ($now, 97200);
          $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
          $self->TicketObj->SetDue($duedate->ISO);
        } elsif ($urgencyvalue eq 'High') {
          $self->TicketObj->SetPriority('75');
          $self->TicketObj->SetFinalPriority('88');
          $duedate->Set(Format=>'unknown', Value=>'15 days');
          $self->TicketObj->SetDue($duedate->ISO);
        } elsif ($urgencyvalue eq 'Medium') {
          $self->TicketObj->SetPriority('50');
          $self->TicketObj->SetFinalPriority('74');
          $duedate->Set(Format=>'unknown', Value=>'3 months');
          $self->TicketObj->SetDue($duedate->ISO);
        } elsif ($urgencyvalue eq 'Low') {
          $self->TicketObj->SetPriority('25');
          $self->TicketObj->SetFinalPriority('49');
          $duedate->Set(Format=>'unknown', Value=>'6 months');
          $self->TicketObj->SetDue($duedate->ISO);
        } elsif ($urgencyvalue eq 'Very Low') {
          $self->TicketObj->SetPriority('1');
          $self->TicketObj->SetFinalPriority('24');
          $duedate->Set(Format=>'unknown', Value=>'1 year');
          $self->TicketObj->SetDue($duedate->ISO);
        } else {
        }
        return(1);

(The Business::Hours library is used by the first three urgency values to 
ensure that short-term tickets come due during our working hours.)


--
Mark Roedel
Webmaster
LeTourneau University


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Jose de Paula 
Eufrasio Junior
Sent: Tuesday, January 19, 2010 10:54 PM
To: rt-users
Subject: [rt-users] Due dates based on custom fields

So, I want to use custom fields to classify the tickets on the support
queue as some pre-defined services. Each service has a defined SLA. I
am also using escalation of tickets based on due date. Is there
anything out that can define the due date of tickets based on those
custom fields? I saw the SLA extension but it looks like SLA per
queue, while what I want is per ticket.

-- 
José de Paula Eufrásio Júnior (coredump)
MCSO, GRC Professional
http://core.eti.br
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [email protected]

2010 RT Training Sessions!
San Francisco, CA, USA - Feb 22 & 23
Dublin, Ireland - Mar 15 & 16
Boston, MA, USA - April 5 & 6
Washington DC, USA - Oct 25 & 26

Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to