Assigned Ticket Duration

jjarka
Kilo Contributor

I am creating a metric called Assigned Ticket Duration.   The goal is to measure the time it took from the creation of the ticket to the first time it was assigned to a resource, not an assignment group.   I did some digging and found this script from another user that I recreated:

1   if (current.asigned_to != ''){

2   createMetric();

3   }

4

5   function createMetric() {

6   var mi = new MetricInstance(definition, current);

7   if (mi.metricExists())

8   return;

9

10   var gr = mi.getNewRecord();

11   gr.start = current.sys_created_on;

12   gr.end = current.sys_updated_on;

13   gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());

14   gr.calculation_complete = true;

15   gr.insert();

16   }

When I ran the script it appears to return results for many records, but there was one where no results had been returned.   It was a test ticket that I created.   I had opened the ticket at 7:40 am assigned it to the Service Desk Group.   At 7:41 I assigned it to another group I set up and then assigned the ticket to me.   I should have a duration of 1 min.  

I must forewarn you, I have limited scripting expertise so I may have messed up the script. Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Line 1. you spelled assigned_to wrong



let me know if you get stuck again


View solution in original post

10 REPLIES 10

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Line 1. you spelled assigned_to wrong



let me know if you get stuck again


Ugh, first row even.   .   I fixed and saved that but still get the same result.


When you say no results returned. You mean that there wasnt created a record in the "instances" for your test record?


Hi Göran,

Enjoyed your presentation at the London release.

This is a very old post. Is there a way in box to measure the time between an incident is assigned to a group and it has been "picked-up/self assigned" by an ITIL user. To measure this time for internal reports, and associate a threshold when it takes to long. Different threasholds for different priorities. 

Can one not use OLA describedhere:

https://docs.servicenow.com/bundle/london-it-service-management/page/product/service-level-management/task/t_CreateAnSLADefinition.html

 Thanks Fredrik