- 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-11-2020 10:52 AM
Yes, even I dont think this will work, because the field we are using is Assignment group, and we are checking for state change in the script.
A business rule may help to set this value.
Thanks,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2020 07:31 AM
@Krishna, Can you please help how can this done with BR?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2018 01:00 PM
Hi - this is probably a bit late but thought it couldn't hurt to reply. I created a bunch of HR Metrics and these were also not closing off. However I just copied the OOTB Incident one, which runs at an order of 10, so before everything else, and closes all metrics on inactive tables...
Screenshot of OOTB metric below.
Hope this helps someone!
Cheers
Carl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2020 12:11 PM
Thank you so much!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2020 12:55 PM
@Carl Fransen
This script work when I am adding it to "Incident" table related Metrics. But not working for HR Case related metrics. Can you please help.