Notification table advance condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-31-2021 06:53 PM
Hi All,
Configured email notification ( table as sys_user) table to send users mail notification
We dont want to send certain group and role exclude users (
Any Idea to add condtion in the advance condition ? saying that group is not xxx and role is not yyy in Notification ( sys_user)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-31-2021 07:46 PM
Thanks
Can we Include parent group name in this script ? like var parent = group.parent.name ?
because In parent group , there are 20+ groups available , which is needs to exclude

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-31-2021 09:13 PM
Hi,
isMemberOf Function will only accomodate one groupname at a time. So you need to add the loop seperately. Do like this.
if (gs.getUser().getUserByID(current.sys_id.toString()).hasRole("<role>") || gs.getUser().getUserByID(current.sys_id.toString()).hasRole("<another role>")) {
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user", current.sys_id.toString());
gr.query();
var flagGroup = false;
while (gr.next()) {
if (gs.getUser().getUserByID(current.sys_id.toString()).isMemberOf(gr.group.name)) {
flagGroup = true;
}
}
if (flagGroup) {
answer = false;
} else {
answer = true;
}
} else {
answer = false;
}
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-31-2021 10:22 PM
Let me try this and update you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-31-2021 10:50 PM
Hey,
Sorry, I think for your scenario, this code will work.
var arrBlockedGroups = ["group1", "group2"]; //Mention all your groups here
if (gs.getUser().getUserByID(current.sys_id.toString()).hasRole("<role>") || gs.getUser().getUserByID(current.sys_id.toString()).hasRole("<another role>")) {
var flagGroup = false;
for (var m = 0; m < arrBlockedGroups.length; m++) {
if (gs.getUser().getUserByID(current.sys_id.toString()).isMemberOf(arrBlockedGroups[m].toString())) {
flagGroup = true;
break;
}
}
if (flagGroup) {
answer = false;
} else {
answer = true;
}
} else {
answer = false;
}
Thanks,
Narsing