CreatePriorityBasedOnCustomFieldValues

From Request Tracker Wiki
Jump to navigation Jump to search

Abstract

We created this scrip for use with ITIL type custom fields. This takes ticket urgency and ticket impact, does some simple math and creates the number for the priority field.

Note that in ITIL priority is determined by ticket urgency and impact, the values of these fields should be low, medium, high, critical. The definition of urgency is simply the amount of time before this task must be completed. The definition of Impact is who/how many people/machines are impacted. These are general definitions you may need to change them based on your working model.

How to install

Create your custom fields for your impact and urgency.

We are using custom field names Ticket_urgency, and Ticket_impact.

  • Name: Ticket_urgency
  • Description: {blank, or put your own description}
  • Type: Select one value
  • Applies to: Tickets
  • Validation: (?#Mandatory).
  • Link Values to: {Blank}
  • Include page: {Blank}
  • Values:
    • 10 - Critical - {Blank} - {Blank}
    • 20 - High - {Blank} - {Blank}
    • 30 - Medium - {Blank} - {Blank}
    • 40 - Low - {Blank} - {Blank}
  • Name: Ticket_impact
  • Description: {blank, or put your own description}
  • Type: Select one value
  • Applies to: Tickets
  • Validation: (?#Mandatory).
  • Link Values to: {Blank}
  • Include page: {Blank}
  • Values:
    • 10 - Critical - {Blank} - {Blank}
    • 20 - High - {Blank} - {Blank}
    • 30 - Medium - {Blank} - {Blank}
    • 40 - Low - {Blank} - {Blank}

Scrip

  • Description: Create Priority
  • Condition: On Transaction
  • Action: User Defined
  • Template: Global template: Blank
  • Stage: Transaction Batch
  • Custom Condition: 1;
  • Custom action preparation code: 1;
  • Custom action cleanup code:
 if($self->TicketObj->Priority > 0){
     return 1;
 }
 else{
     my $urgent = $self->TicketObj->CustomFieldValues('Ticket_urgency');
     my $impact = $self->TicketObj->CustomFieldValues('Ticket_impact');
     my $urg = $urgent->Next->Content;
     my $imp = $impact->Next->Content;
     $RT::Logger->error( "Urg: ".$urg
 );
     $RT::Logger->error( "Imp: ".$imp
 );
     my $urgn = "60" if ($urg =~ /^C/); #Critical
     $urgn = "45" if ($urg =~ /^H/); #High
     $urgn = "30" if ($urg =~ /^M/); #Medium
     $urgn = "5" if ($urg =~ /^L/); #Low
     my $impn = "30" if ($imp =~ /^C/); #Critical
     $impn = "20" if ($imp =~ /^H/); #High
     $impn = "10" if ($imp =~ /^M/); #Medium
     $impn = "5" if ($imp =~ /^L/); #Low
     my $pri = $urgn + $impn;
     $self->TicketObj->SetPriority ($pri);
     1;
 }

Here is a visual representation of this table: Across is Ticket Impact Down is urgency

Critical High Medium Low
Critical 90 80 70 65
High 75 65 55 50
Medium 60 50 40 35
Low 35 25 15 10

This allows room for moving the priority as needed, ITIL States that urgency and impact should not be changed through the life cycle of the ticket, that is the reason for the if statement at the beginning of the scrip, this allows you to change the priority with out changing the initial impact or urgency.


By: Tc3driver -- Any questions hit me up on the list