Want to create a MTTR Response incident report

MayurChaudhari
Tera Contributor

I Want to create a MTTR Response incident report from 'Created to Assigned to'. Need to calculate time duration from Incident created to gets assigned to someone. 

 

This is Metric Definition for 'Create to Resolve Duration'

MayurChaudhari_0-1724671472941.png

 

Code - 

 

// variables available
// current: GlideRecord -  target incident
// definition: GlideRecord -  (this row)
var s = current.incident_state;
if (s >= 6)
  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.getDisplayValue(), gr.end.getDisplayValue());
  gr.calculation_complete = true;
  gr.insert();
}
 
- What changes I have to make in it to create a Metric Definition for 'Create to Assigned to'.
Please guide me on this.

 

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @MayurChaudhari 

 

I think response SLA will solve your problem, as soon as the incident assigned, the response SLA will be stopped and you can use that for calculation. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hello @Dr Atul G- LNG 

I have followed your way but client dont want it in this way, I have to create it by Metric Definition for 'Create to Assigned to'. Any suggestion what should i make changes in script so that I can use it.

Hi @MayurChaudhari 

 

For me, you are an expert in SN and you should guide clients on what is good and what is bad. Scripting will increase technical debt. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG 

Absulutly agree with you. But client wants to follow this way. Because we have already created a reports for Incident Resolution by using Metric Definition 'Created to resolved incident'. Clients want to follow same way for incident 'Create to Assigned to'