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

Average Resolution Time Based on Business Hours

KirstinR
Mega Expert

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.

8 REPLIES 8

Slawek_Radziewi
Kilo Sage

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.



find_real_file.png



On new script form you define what fields should be used from the table by the script.


find_real_file.png


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!

Padmanabam Tiru
ServiceNow Employee
ServiceNow Employee

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...


Josh Cooper
ServiceNow Employee
ServiceNow Employee

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.