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

Hi Fredrik,

 

Well, it's possible. But OLA isn't really used for that. OLA is used to measure internal services and when having the whole picture, you create the SLA against the customer. E.g. you have a OLA against server team that a new server takes 20 hours to setup. With that information, it would be suicide to write a SLA towards the customer with a SLA for 4 hours on that specific service.

 

But, if you are with London release, you should be able to use the SLA Breakdowns to actually get this information. Since it already doing those calculations for you. So if you isn't on the London release, I would see if you can wait until you upgrade to that, just to get the OOB functionality instead of spending hours trying achieve something that actually comes OOB in London.

 

//Göran

Hi Göran, We are on Jakarta,

Is this what we would use in London to measure time  between an incident is assigned to a group and it has been "picked-up/self assigned" by an ITIL user. ?

https://docs.servicenow.com/bundle/london-it-service-management/page/product/service-level-management/reference/installed-with-sla-breakdowns.html#installed-with-sla-breakdowns

Thanks Fredrik

Hi Fredrik,

 

Sorry for the late reply, but I didn't notice it until now. Yes, that would be something. But if I understand you correct I would rather actually use a metric for that. With that you can easy measure the time from the incident was created until someone assigned it to a user.

 

//Göran
Feel free to connect with me:
  [Please purchase a license i

jjarka
Kilo Contributor

Goran,



No, I mean that when I look at the results, the did not change at all from the previous scripting.


Not sure if I understand you correctly, but the metrics only runs once per record. so if you change the script it won't run the records it already have.