Average Resolution Time Based on Business Hours

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:37 AM
I would like to calculate the "Average Resolution Time" based on our business hours.
I have created:
2 Automated Indicators:
1) Summed Duration of Closed HR Cases
2) Number of Closed HR Cases
1 Formula Indicator: ([[Summed duration of closed HR Cases]] / [[Number of closed HR Cases]]
I am not very familiar with script so I have found the following script in the SN community which I am using in the Summed Duration automated indicator. How would I incorporate a specific schedule into the script?
var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var days=function(x,y){return diff(x,y)/(24*60*60*1000);};
days(current.sys_created_on, current.sys_updated_on);
Thank you in advance for your help.
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2018 08:59 AM
Hi
Formula in my case is: ([[Summed duration of resolved incidents]] / [[Number of resolved incidents]]) / 60 / 60 / 24
I have seconds and I need days so I divide this way.
In "Summed" automatic indicator you choose script or create a new one if there is no such.
On new script form you define what fields should be used from the table by the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2021 11:58 AM
when I use this code, i get the same value for every month. It doesn't seem to be using the period per the indicator source? I saw another discussion about having to use 'score_end' or 'score_start' for scripts to work on automated indicators? I am simply trying to get average durations on the task [task] table in pa.
Any suggestions? Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 08:11 AM
Hi Kirstin, Please go through the below link, it gives you details and examples how to use GlideSchedule and load schedule to calculate business duration between two dates. https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 10:24 AM
If you have the option, you might also take a look at the business rules attached to the Incident table. I believe there's a field on incidents that calculates the 'business duration' (which uses the system default schedule). If you have access to see Incident's business rules, you may be able to search the script field for the name of the business duration field, and see what updates it - that may give you a good place to start for your HR calculation.