Metrics : On resolve state after reopen the incident.

Nageshwari P
Tera Contributor

Hi Team,
I have a requirement that, when the incident ticket is resolved then the metric "create to set resolved duration " is calculated and the resolved time on incident and the metric end time is matching.
But, when the incident ticket is reopened and resolved it again then the actual resolved time in Incident ticket and the end time in metric is not matching.
Can I know how to resume the metric and calculate the actual resolved time after reopen and resolved, and the end time in metrics do match?

Thanks and Best Regards,
Nageshwari P.

1 ACCEPTED SOLUTION

Hello @Nageshwari P 

 

Those are just comments you can set it to backend values of resolved. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

View solution in original post

10 REPLIES 10

Nageshwari P
Tera Contributor

I have created a business rule to populate the Metric whenever we reopen and resolve the ticket. It is working as expected but the duration field is not getting updated.
Whenever I am using the commented script, the metric is not getting assigned. Can you please help me the resolve this issue.

if (previous.state != 6 && current.state == 6) {

// check if it was reopened before resolving

if (current.reopen_count > 0) {

var metric = new GlideRecord('metric_instance');

metric.initialize();

metric.name = 'Create to Resolve Duration';

metric.definition = '35edf981c0a808ae009895af7c843ace'; //metric definition sys_id

metric.id = current.sys_id;

var now = new GlideDateTime();

metric.start = current.sys_created_on;

metric.end = now;

//var sched new GlideSchedule('ba7530901bcf2450988887f7cc4bcb8b');

//var dur = sched.duration(metric.start,metric.end);

//metric.duration dur.getDurationValue();

metric.value = current.incident_state.getDisplayValue();

metric.calculation_complete = true;

metric.insert();

gs.info("Duration Set:" + metric.duration + "| Inserted: " + metric.sys_id);

gs.info("Metric created for " + current.number + " after reopen.");

}