Metric Definition Code

MarripudiL
Tera Contributor

Hi All,

 

How to calculate the time taken from open to resolved state excluding onhold on incident table.

 

Thanks in advance

 

2 REPLIES 2

Kieran Anson
Kilo Patron

I'd recommend reviewing the below YT Video. In short, an existing metric definition (Incident State Duration) is capturing this information. You just need to create an indicator source, and script to sum the data

 

https://www.youtube.com/watch?v=g4Ee73HQU7w 

 

Shivalika
Mega Sage

Hello @MarripudiL 

 

First Run GlideAggregate on incident_metric table with value as "on hold" for the incidents. GlideAggregate as SUM. 

 

You need to store this value in GlideDuration type field and convert it to milliseconds. 

 

Next, find the milliseconds difference between gs.dateDiff(sys_created_on, resolved time) 

 

Then subtract the OnHold milliseconds value from this. 

 

I have already implemented this in my customer instance and storing the percentage in a custom field. So please follow this way, it should work. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

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

 

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