- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 07:37 AM
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
Solved! Go to Solution.
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 08:37 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 08:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 08:51 AM
Thank you for the reply.
I think I got what i need with what I posted below.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 08:37 AM
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