The CreatorCon Call for Content is officially open! Get started here.

PAIN Value Calculation

karl_james
Kilo Explorer

Hi All

I've been pretty good with my scripting within SN but I'm having an issue that I'm hoping someone can help with. Our Problem Manager asked for a PAIN value field to be added to our problem form, which is all good.

I'd like to write a script to calculate the PAIN value and populate the field to save some time and increase accuracy of the values for reporting. Below is the calculation to get this value:

(V x Y) x Z = PVC

V = Severity of each related Incident

  • Severity 1 = 1000 points
  • Severity 2 = 800 points
  • Severity 3 = 500 points

Y = Number of related Incidents x V

Z = Total Outage Hours x Y

Has anyone done anything like this before?

1 ACCEPTED SOLUTION

Your X and Y values ...



var severityArray = [];
severityArray["1"]=1000;
severityArray["2"]=800;
severityArray["2"]=500;


var X = severityArray[current.severity];


var count = new GlideAggregate('incident');
count.addEncodedQuery('parent='+current.sys_id);
count.addAggregate('COUNT');
count.query();
var Y = 0;
if (count.next())
Y = count.getAggregate('COUNT');


View solution in original post

15 REPLIES 15

http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#dateDiff.28String.2C_...


this will give you the Z value in second.. Convert this to hours ...


And if the question was answered, Please click on the Correct Answer and/or Helpful Answer buttons on the appropriate reply/replies if any and close of the loop. This helps other users to see that a valid response was received.



Hope your PAIN values is 'No PAIN' now


Your X and Y values ...



var severityArray = [];
severityArray["1"]=1000;
severityArray["2"]=800;
severityArray["2"]=500;


var X = severityArray[current.severity];


var count = new GlideAggregate('incident');
count.addEncodedQuery('parent='+current.sys_id);
count.addAggregate('COUNT');
count.query();
var Y = 0;
if (count.next())
Y = count.getAggregate('COUNT');


Thanks so much for this! Looks like I need to go CodeAcademy and redo arrays!


Karl, I'll also add, Outage records already have a calculated duration, you can just use that rather than re-calculating it yourself.