- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:43 AM
I have created a metric which store duration how much time a assignment group is taking. but this metic should end when ticket is closed
calculation should complete and metric should provide duration when ticket is closed or inactive
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 08:50 PM
Hi Alikutty,
below is the code which i found from communities which is running for me,
if (current.state == 6) { //change according to your closed state
answer = false;
mi.endDuration();
closeDurations(mi.current);
}
function closeDurations(current) {
var gr = new GlideRecord('metric_instance');
gr.addQuery('id', current.sys_id);
gr.addQuery('calculation_complete', false);
gr.addQuery('definition.type', 'field_value_duration');
gr.addQuery('definition', '39d43745c0a808ae0062603b77018b90'); //mark your metric definition sysid
gr.query();
while (gr.next()) {
var definition = new GlideRecord('metric_definition');
definition.get(gr.definition);
var mi = new MetricInstance(definition, current);
mi.endDuration();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2020 01:45 PM
Got it...Thank you so much. Currently, I am trying to make "Duration" (Total time) to get work, but eventually, will need Business duration. Thank you for pointing out that.
One more question, I need a report on "Assignment group" - once value change to "HR Tier 2 (Escalated), how much time it take for someone to Assign ticket to themselves. I created Assignment group metric. but its giving total time (as assignment group value is not changing) Is there any better way to do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2020 01:57 PM
That's an interesting one as these two metrics are quite different and calculated separately - the assignee metric only captures how long the assignee had it, not how long when assigned to group 'x'. I would look to create a new question in the community to see if anyone has combined two measures into the one metric...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2020 02:01 PM
Yes...these are two separate metrics.....Assignment group & Assigned to.....
I will create a separate question.....thank you so much for all your guidance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2020 12:03 PM
I had to set my order to 110 (instead of 10) to get this to work as expected. That way it runs after the other Metrics and closes them.