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
Monday - last edited Monday
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
Tuesday - last edited Tuesday
this is the log that i have printed it is coming but alerts are not grouping for the rule which matches
CODE which is have written:
@Ankur Bawiskar
@TejasSN_LogicX
can you guy'z help me in debugging thnx in advance.!
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
Tuesday
try to use GlideAggregate
var alertGrCount = new GlideAggregate(table);
alertGrCount.addEncodedQuery("sourceLIKEIRIS^severity=4^state!=Closed^parentISEMPTY");
alertGrCount.groupBy('parent');
alertGrCount.query();
var totalMatchingAlerts = 0;
while (alertGrCount.next()) {
totalMatchingAlerts++;
}
gs.info("Total matching alerts: " + totalMatchingAlerts);
// Only group if exactly 3 alerts match
if (totalMatchingAlerts === 3) {
var alertGr = new GlideRecord(table);
alertGr.addEncodedQuery("sourceLIKEIRIS^severity=4^state!=Closed^parentISEMPTY");
alertGr.orderByDesc("sys_created_on");
alertGr.setLimit(3);
alertGr.query();
var storeID = [];
while (alertGr.next()) {
storeID.push(alertGr.getUniqueValue());
}
gs.info("Alerts to group: " + storeID);
var result = {
"parent": storeID
};
var getStr = JSON.stringify(result);
gs.info("Grouping result: " + getStr);
return getStr;
} else {
gs.info("Not grouping alerts since count != 3");
return false;
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
let me try
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
Tuesday
tried but failed, it is not picking 3 as count applied logs
CODE :
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
Wednesday
did you get time to review this ? @Ankur Bawiskar
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
