- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 11:09 AM
Hi,
I need to create a report to exhibit some statistics related to TWO SIMULTANEOUS conditions:
State = On Hold
Assignment Group = XYZ
Incident Metric table as is won't help me, since the Definition Values I need are separated from each other. I am starting to thinking that a NEW Definition [Scripted] my be the solution but wouldn't want to go that waiy if there's something already in place that I am not seeing / not aware of.
Any ideas or suggestions on how to approach this?
Thanks in advance,
CSA - CIS PA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 11:09 AM
You are welcome, I'm glad I was able to help. You can use an "After" business rule defined on the incident table, with condition: "Assignment group", "changes from", "Hardware" (ABC in your example). with Advanced checked and script:
closeMetric('c06cbfdf477b6110753923dbd36d43a8', current.sys_id);
function closeMetric(def_sys_id, inc_sys_id) {
// var mir = m_i.metricExists(); just returns T/F, so query for existing record
var gmr = new GlideRecord('metric_instance');
gmr.addQuery("id", inc_sys_id);
gmr.addQuery("definition", def_sys_id);
gmr.addQuerry('value', 'On Hold');
gmr.query();
// gs.info("groupOnHoldDuration: closeMetric: found: " + gmr.getRowCount() + " records for id: " + inc_sys_id);
if (gmr.next()) {
gmr.end = new GlideDateTime();
gmr.duration = gs.dateDiff(gmr.start.getDisplayValue(), gmr.end.getDisplayValue());
gmr.calculation_complete = true;
// gs.info("groupOnHoldDuration: closeMetric: setting end: " + gmr.end);
gmr.update();
}
}
Good luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 05:44 PM
Hi LuisMarcel,
the metric definition works as long as the assignment_group doesn't change while the 'incident_state' remains On-Hold. To stop the metric when the assignment_group changes, the BR logic is needed. The interested group should not be impacted by On-Hold duration when another group has the incident.