- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2019 08:22 PM
Hello Team,
Hello,
I am looking for calculating the MTTR value for resolved/Closed incident. Let say i have pulled the count of total resolved/closed ticket for a particular group now how to calculate the MTTR value.I don't want to create the MTTR report just need the value , i need to populate this value only.
I have tried to calculate this from task_sla table.
In the below code pulling the incident and passing the incident sys_id in the task_sla table and filtering only resolution SLA. But i am not able to find out why i am not getting the value of business duration.
Please suggest.
var result = 0;
var gr = new GlideRecord('incident');
var querystring3="caller_id=1bcd25cbdb9b1300973056d6dc96191b^sys_created_on>javascript:gs.dateGenerate('2018-12-14','23:59:59')^assignment_group=989e415ddb77fa403eb17e400f9619ba^state=6^ORstate=7";
gr.addEncodedQuery(querystring3);
gr.query();
var count3 =0;
count3=gr.getRowCount();
gs.print("Count"+count3);
while(gr.next())
{
var gr1= new GlideRecord('task_sla');
gr1.addQuery('task','gr.sys_id');
gr1.addEncodedQuery("slaLIKEResolution");
gr1.query();
result += gr1.business_duration;
gs.print("number"+gr.number);
gs.print("Result"+result);
}
Thanks,
Manish
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 03:16 AM
Thanks Tony for your input.
This code seems to be working fine.
var result=0;
var days = 0;
var second=0;
var mttr=0;
var myDate = gs.nowDateTime();
var gr = new GlideRecord('incident');
var querystring3="caller_id=1bcd25cbdb9b1300973056d6dc96191b^sys_created_on>javascript:gs.dateGenerate('2018-12-14','23:59:59')^assignment_group=989e415ddb77fa403eb17e400f9619ba^state=6^ORstate=7";
gr.addEncodedQuery(querystring3);
gr.query();
var count3 =0;
count3=gr.getRowCount();
gs.print("Count"+count3);
while(gr.next())
{
var gr1= new GlideRecord('task_sla');
gr1.addQuery('task',gr.sys_id);
gr1.addEncodedQuery("slaLIKEEurostar_Resolution");
gr1.query();
while(gr1.next()){
myDate = gr1.business_duration;
var gdt1 = new GlideDateTime(myDate);
var epoch = gdt1.getNumericValue();
result +=epoch;
second=result/1000;
hours=second/3600;
mttr=hours/count3;
gs.print("number"+gr.number);
}
}
gs.print("Result"+result);
gs.print("Second"+second);
gs.print("hours"+hours);
gs.print("MTTR hours"+mttr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 12:24 AM
Thanks Tony,
Getting the output but in epoch format like (1970-01-01 00:03:201970-01-01 00:03:461970-01-01 00:03:171970-01-01 00:02:54), need the business_duration in desires format (14 Days 15 Hours 30 Minutes).
Any suggestion to convert this epoch format.
Thanks,
MAnish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 12:41 AM
Hi, off the top of my head I'm not 100% sure of the code.
You will need to subtract epoch from the returned time stamp and then convert the remainder to a date\time value.
It shouldn't be too difficult and I am sure it has been asked before\the answer is already on the forum somewhere.
You should also take a look at the date\time APIs in case it's already covered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 03:16 AM
Thanks Tony for your input.
This code seems to be working fine.
var result=0;
var days = 0;
var second=0;
var mttr=0;
var myDate = gs.nowDateTime();
var gr = new GlideRecord('incident');
var querystring3="caller_id=1bcd25cbdb9b1300973056d6dc96191b^sys_created_on>javascript:gs.dateGenerate('2018-12-14','23:59:59')^assignment_group=989e415ddb77fa403eb17e400f9619ba^state=6^ORstate=7";
gr.addEncodedQuery(querystring3);
gr.query();
var count3 =0;
count3=gr.getRowCount();
gs.print("Count"+count3);
while(gr.next())
{
var gr1= new GlideRecord('task_sla');
gr1.addQuery('task',gr.sys_id);
gr1.addEncodedQuery("slaLIKEEurostar_Resolution");
gr1.query();
while(gr1.next()){
myDate = gr1.business_duration;
var gdt1 = new GlideDateTime(myDate);
var epoch = gdt1.getNumericValue();
result +=epoch;
second=result/1000;
hours=second/3600;
mttr=hours/count3;
gs.print("number"+gr.number);
}
}
gs.print("Result"+result);
gs.print("Second"+second);
gs.print("hours"+hours);
gs.print("MTTR hours"+mttr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 09:55 PM