Metric OOO definition script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 05:40 AM
Hi Team,
Can anyone please help us what the below OOB script is executing?
what the function is indicating here ??
if (!current.active) {
answer = false;
mi.endDuration();
closeDurations(mi.current);
}
// this function
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.query();
while (gr.next()) {
var definition = new GlideRecord('metric_definition');
definition.get(gr.definition);
var mi = new MetricInstance(definition, current);
mi.endDuration();
}
}
Thanks,
Lara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 06:40 PM
Hi, unfortunately your question is not clear and your script appears truncated, is it this metric definition.
/metric_definition.do?sys_id=39d631fcc0a808ae00486d7bad874380&sysparm_record_target=metric_definition&sysparm_record_row=1&sysparm_record_rows=14&sysparm_record_list=ORDERBYorder
The script looks up the metric_instance table for existing\matching metric instances for the current object (IE incident record), for each result it runs the MetricInstance().endDuration() function passing in parameters of the metric definition involved and the current (object) incident record).
if it finds a match the metric instance is updated.