Write Script to Calculate Time to Resolve/Closed - MTTR (Task Table)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 05:59 AM
Hi All,
I am trying to create a report on task table (Inc & SC Task only) for MTTR. We need to calculate time duration from opened to resolved for Incident and Opened to Closed for Sc_Tasks.
Can we write a script on task table to compare these two values and get summed duration on indicators for MTTR metric?
I am aware we have OOO reports on incident table and we have customized it for sc_task table however this time we want this on task table (task) so need help how to script this?
Below is script used OOO
var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var hours=function(x,y){return diff(x,y)/(60*60*1000);};
hours(current.opened_at, current.closed_at);
We have reached till here and unable to modify script to get comapre values to get duration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 11:06 PM
You could use the metrics table for this. It's already in place (probably just need to create some new ones so you have it for the correct table (do know that the values used on task table can cause different calculations since state is a tricky one to report on on task level).
If my answer helped you in any way, please then mark it as helpful.
Mark
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 10:26 AM
Hi Eddie,
I have a similar requirement to calculate MTTR, can you please share the steps you did for the report creation, your help is much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2022 11:46 AM
Hi Kamleshwar, we have calculated both on different tables. for incident calculated in incident table and for tasks, calculated on sc_task table using OOB script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 03:08 AM
I need to add 'vendor' as a breakdown and it extends from the assignment group.
each vendor has its own schedule and if I use this OOTB scrip it will calculate only from opened and resolved duration and will not consider the assignment group schedule, in this case how to add the schedule part of this calculation , can you guys help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 10:42 PM
Having to use schedules based on vendor I think you will be best of (mis)using the SLA Definition-table for this. Start on 'opened', stop on 'closed/resolved' and use the schedules. That will make the easiest way to report.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark