- 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
05-11-2017 04:02 AM
It seems like some issue in the instance. Can you check the same on a developer instance once?
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 04:05 AM
ok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 02:54 AM
Hi , i have checked on other env also but code is not working, can you check in your instance by removing that code , last metrics should be false only, why i am asking this is to check that metrics is stopping or not when you are not writing code
- 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
07-29-2020 11:37 PM