The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Scripted Indicator is not working a expected

lucaalthoff
Tera Contributor
Hello ServiceNow Community, I’m working on creating a scripted indicator that calculates the number of incidents resolved by the first assigned group. To achieve this, I wrote a script that checks the incident_metric table. The script ensures that, for each incident (using the inc_sys_id), only entries with identical mi_values are considered. During testing, the script seemed to work fine. However, when running the job collection, the indicator consistently returns a value of 1 as the result. Does anyone have an idea what might be causing this issue? function checkCurrentConsistency(inc_sys_id) { var currentSysId = inc_sys_id; var ga = new GlideAggregate('incident_metric'); ga.addQuery("inc_resolved_atONToday@javascript&colon;gs.beginningOfToday()@javascript&colon;gs.endOfToday()^inc_state!=8^mi_definition=39d43745c0a808ae0062603b77018b90^mi_valueISNOTEMPTY"); ga.query(); if (!ga.hasNext()) { return false; } var sysIdMap = {}; while (ga.next()) { var sys_id = ga.getValue('inc_sys_id'); var miValue = ga.getValue('mi_value'); if (!sysIdMap[sys_id]) { sysIdMap[sys_id] = []; } sysIdMap[sys_id].push(miValue); } if (currentSysId in sysIdMap) { var first = sysIdMap[currentSysId][0]; for (var i = 1; i < sysIdMap[currentSysId].length; i++) { if (sysIdMap[currentSysId][i] != first) { return false; } } return currentSysId; } else { return false; } } checkCurrentConsistency(current.inc_sys_id);
0 REPLIES 0