Report help - created to first updated metric

Travers M
Mega Guru

This one might be easy and I'm just missing it but I'm looking to create a report for incidents that shows a report that shows the time elapsed from when a ticket was created to when it was first addressed/updated.   I know the numbers may be a bit misleading as we aren't a 24/7 shop and the times would be ticking during off hours so if anyone would know a magic trick to keep that out I'd be most grateful.  

1 ACCEPTED SOLUTION

Hopefully this helps you out, I got the same message that you did when I clicked the original links.  



I created a new metric definition.   On the incident table and the incident state field and the type was script calculation with the following script;



// variables available


// current: GlideRecord -   target incident


// definition: GlideRecord -   (this row)


if (current.sys_mod_count == 1)


  createMetric();



function createMetric() {


  var mi = new MetricInstance(definition, current);


  if (mi.metricExists())


      return;



  var gr = mi.getNewRecord();


  gr.start = current.sys_created_on;


  gr.end = current.sys_updated_on;


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


  gr.calculation_complete = true;


  gr.insert();


}



I'm looking for the report I was running that pulled the the average time to address but just can't find it.   I really dislike the layout for the reports in Fuji but that's another gripe for another time.     Let me know if this is what you needed and I'll keep looking for that report if you'd like to see it.


View solution in original post

8 REPLIES 8

Hopefully this helps you out, I got the same message that you did when I clicked the original links.  



I created a new metric definition.   On the incident table and the incident state field and the type was script calculation with the following script;



// variables available


// current: GlideRecord -   target incident


// definition: GlideRecord -   (this row)


if (current.sys_mod_count == 1)


  createMetric();



function createMetric() {


  var mi = new MetricInstance(definition, current);


  if (mi.metricExists())


      return;



  var gr = mi.getNewRecord();


  gr.start = current.sys_created_on;


  gr.end = current.sys_updated_on;


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


  gr.calculation_complete = true;


  gr.insert();


}



I'm looking for the report I was running that pulled the the average time to address but just can't find it.   I really dislike the layout for the reports in Fuji but that's another gripe for another time.     Let me know if this is what you needed and I'll keep looking for that report if you'd like to see it.


Thanks, this is my 'side -project' so I wont get back to it for a while.


Will message you when I have tested it


Thanks again.


report.jpg



I found the report.   Update times is what I called the metric when I created it.   The mi_duration under selected was the returned time from the metric.


Hi,

This script is not returning correct values. 

Please let me know if this script is capable of capturing values in seconds