group alerts if there are 3 alerts if not dont group them
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
requirement is if 3 alerts is created in servicenow , group them which is working but now what is happening is 3 alerts are created but this rule is not matching and showing some different rule in activites under work notes ,some other rule is taking precendence. ..so now if 4 alerts re created it should not group it
pls can someone help me where i am going wrong..
in the below picture it is creating a new alert instead of making 607 as parent which is expected
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @AnimeshP_96 ,
logic
(function findCorrelatedAlerts(currentAlert) {
var groupByField1 = currentAlert.resource;
var groupByField2 = currentAlert.metric_name;
var groupCondition = new GlideRecord('em_alert');
groupCondition.addQuery('resource', groupByField1);
groupCondition.addQuery('metric_name', groupByField2);
groupCondition.addNullQuery('parent');
groupCondition.addQuery('sys_id', '!=', currentAlert.sys_id);
groupCondition.query();
var existingAlerts = [];
while (groupCondition.next()) {
existingAlerts.push(String(groupCondition.getUniqueValue()));
}
if (existingAlerts.length === 2) {
gs.info("Custom 3-Alert Rule: SUCCESS. Grouping " + existingAlerts.length + " alerts under Parent: " + currentAlert.number);
return JSON.stringify({
'parent': existingAlerts
});
} else {
gs.info("Custom 3-Alert Rule: FAILURE. Found " + existingAlerts.length + " matching ungrouped alerts. Requires exactly 2 for grouping.");
return JSON.stringify({
'parent': []
});
}
})(currentAlert);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
21 hours ago
let me try @TejasSN_LogicX thnx
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
23 hours ago
what debugging did you do?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
21 hours ago
so first log : gs.info("this is li3ne 13 from me"); this is printed 6 times in log table but it should be 3 becuase setlimit(3) is provided in the script
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
