- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 07:26 AM
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?
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:02 AM
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');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:07 AM
this will give you the Z value in second.. Convert this to hours ...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:10 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:02 AM
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');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:31 AM
Thanks so much for this! Looks like I need to go CodeAcademy and redo arrays!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2015 03:14 AM
Karl, I'll also add, Outage records already have a calculated duration, you can just use that rather than re-calculating it yourself.