- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 12:59 PM
I wrote a script for a metric that checks Incidents that have been resolved by a certain group(Service Desk) without escalation or assigning the ticket to other groups within the span of 24 hours.
My computation of the duration is pretty straight forward, date difference between created time and resolved time if it is less than 24 hours then the incident gets added to the list.
The problem is the customer wants sort of like a pause condition similar to how an SLA would work. The customer doesn't want the time running if the ticket state is pending vendor or something with pending.
Is there a way to do this? Probably capture the time spent while the ticket was on pending state which I could just subtract from my current computation or something?
Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 01:12 PM
Hi Sean,
You can create a Metric definition for Incident State changes.
Name: Incident State Changes
Table: Incident
Field: Incident State
Type: Field value duration
Once done, you'll start getting the records in the metric instance table (metric_instance). Capture the records whose
1. Definition = Incident State Changes,
2. Value != All Awaiting states
Now dump all these records in a seperate table and write a script to add the duration of all matching incidents.
Hope this will help!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 01:03 PM
Hi Sean,
I think at metric script level you can control. Something like
if(current.state == '2'){
answer = false;
}else{
answer = true;
}
Adjust as per your req.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 01:29 PM
Hi Pradeep,
Thank you for your feedback.
Please correct me if I am wrong. The suggestion you gave is designed to not execute my code if it has been set to pending and will execute my script if it is not pending. Right?
If this is so then there may be inconsistencies with the results.
Lets say a ticket was created and was worked on by service desk without being escalated for 23 hours then they decide to put the ticket on pending for 1 minute then decide to put it back to open or what not. I am afraid that the metric will not interpret it as it was paused for 1 minute but may redo my computation from the start or compute for the total duration as if it started from scratch.
var dif = gs.dateDiff(current.opened_at.getDisplayValue(),current.resolved_at.getDisplayValue(),true); -- this is how I currently get the total duration spent working on the ticket. It the ticket gets paused (Set to Pending) I need to make sure that it continues counting where it left off or something.
I appreciate your help on this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 01:35 PM
Hi Sean,
Thanks for the update. I am not sure if it will append or start the time from scratch.
I have to check and update you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2016 01:12 PM
Hi Sean,
You can create a Metric definition for Incident State changes.
Name: Incident State Changes
Table: Incident
Field: Incident State
Type: Field value duration
Once done, you'll start getting the records in the metric instance table (metric_instance). Capture the records whose
1. Definition = Incident State Changes,
2. Value != All Awaiting states
Now dump all these records in a seperate table and write a script to add the duration of all matching incidents.
Hope this will help!!