Reporting on State duration per assigned to or updated by

Chris101
Tera Expert

Hello, 

I have a requirement to report on an average time of a work in progress state per person. When a tech opens a ticket the first thing they do is assign to themselves and set the state to work in progress. I am trying to see how much time each person is spending in work in progress. I know there are metric that shows incident state duration but it does not show who it was assigned to at that time or who made the update to the state. Any help would be appreciated.  

 

 

Thank you

1 ACCEPTED SOLUTION

Chris101
Tera Expert

I may have corrected my own answer by reworking an existing process I have but I would like to post my solution to see if anyone would like to chime in. 

I created a metric definition on the state field 'Incident State Duration WIP by assigned' as a script calculation and left the script blank. 

I then created 2 business rules. 

First Business rule ->before insert/update ->condition is when state changes to 'work in progress'. 

business rule script. 

(function executeRule(current, previous /*null when async*/) {

var mi= new GlideRecord('metric_instance');
//sys id of the metric definition
var metricSysID = '56be22ce1b5fdc5013eec99f034bcbea';

mi.initialize();
mi.definition = metricSysID;
mi.start = gs.nowDateTime();
mi.id = current.sys_id;
mi.value = gs.getUser().getFullName();
mi.calculation_complete = false;
mi.insert();

})(current, previous);

 

Second Business rule ->before insert/update ->condition is when state changes from 'work in progress'. 

 

(function executeRule(current, previous /*null when async*/) {

//sys id of the metric definition
var metricSysID = '56be22ce1b5fdc5013eec99f034bcbea';
var mi= new GlideRecord('metric_instance');

mi.addQuery('id',current.sys_id);
mi.addQuery('definition',metricSysID);
mi.addQuery('calculation_complete', false);
mi.query();

if(mi.next()){


    mi.end = gs.nowDateTime();
    mi.duration = gs.dateDiff(mi.start, mi.end);
    mi.calculation_complete = true;
    mi.update();


}


})(current, previous);

 

 

Now I can report on metric definition 'Incident State Duration WIP by assigned' and group by the value which will give the name of the person that made the state change to work in progress. 

 

Thank You

View solution in original post

3 REPLIES 3

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to use performance analytics to do this kind of reporting.

You need to configure PA indicators, breakdowns to see this kind of scores.

Take a look into below PA OOB dashboard on your personal instance to get an idea

 

find_real_file.png

 

Regards,

Sachin

Thank you for the reply.

 

I think I got what i need with what I posted below. 

 

 

Thank you

Chris101
Tera Expert

I may have corrected my own answer by reworking an existing process I have but I would like to post my solution to see if anyone would like to chime in. 

I created a metric definition on the state field 'Incident State Duration WIP by assigned' as a script calculation and left the script blank. 

I then created 2 business rules. 

First Business rule ->before insert/update ->condition is when state changes to 'work in progress'. 

business rule script. 

(function executeRule(current, previous /*null when async*/) {

var mi= new GlideRecord('metric_instance');
//sys id of the metric definition
var metricSysID = '56be22ce1b5fdc5013eec99f034bcbea';

mi.initialize();
mi.definition = metricSysID;
mi.start = gs.nowDateTime();
mi.id = current.sys_id;
mi.value = gs.getUser().getFullName();
mi.calculation_complete = false;
mi.insert();

})(current, previous);

 

Second Business rule ->before insert/update ->condition is when state changes from 'work in progress'. 

 

(function executeRule(current, previous /*null when async*/) {

//sys id of the metric definition
var metricSysID = '56be22ce1b5fdc5013eec99f034bcbea';
var mi= new GlideRecord('metric_instance');

mi.addQuery('id',current.sys_id);
mi.addQuery('definition',metricSysID);
mi.addQuery('calculation_complete', false);
mi.query();

if(mi.next()){


    mi.end = gs.nowDateTime();
    mi.duration = gs.dateDiff(mi.start, mi.end);
    mi.calculation_complete = true;
    mi.update();


}


})(current, previous);

 

 

Now I can report on metric definition 'Incident State Duration WIP by assigned' and group by the value which will give the name of the person that made the state change to work in progress. 

 

Thank You