
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 03:40 AM
Im kicking off a event from a scheduled job that checks for a users end date daily. If the end date is today, it should send a notification to our ServiceDesk. This part works.
In the Notification I am adding an advanced condition that should only send the notification if the user that is on its end date is a member of a specific group in ServiceNow. I am using the code below but it always returns false and does not send the notification.
var groupMember = gs.getUser();
if(groupMember.isMemberOf('GROUPNAME'))
{
answer = true;
}
else
{
answer = false;
}
.
Solved! Go to Solution.
- Labels:
-
Notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2022 10:39 PM
Note:
1. Assuming you are trying to trigger notification for the user record.
2. Change the variable group_name value and use the code.
var group_name = "Please set your group name here to check";
var user_sys_id = current.sys_id;
var userOb = new GlideUser().getUserByID(user_sys_id);
if (userOb.isMemberOf(group_name)) {
answer = true;
} else {
answer = false;
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 03:45 AM
is this a scoped app ?
also try this script
if(gs.getUser().isMemberOf('GROUPNAME'))
{
answer = true;
}
else
{
answer = false;
}
PLEASE MARK MY ANSWER CORRECT IF THIS HELPS YOU

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 04:11 AM
I changed the script to what you provided but the result is the same. I don't think its a scoped app, but how do I check this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 03:54 AM
Hi, you can try this as well,
var ourUser = gs.getUserID();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', ourUser); // checking user sys id here.
gr.addQuery('group', 'GROUP_SYSID');// enter youe group sys id here
gr.query();
if(gr.next()) {
answer = true;
}
else {
answer = false;
}
PLEASE MARK MY ANSWER CORRECT IF THIS HELPS YOU

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 05:24 AM
Unfortunately this doesnt seem to work. It always returns true, both for users that are member of the group, and for users that are not member of the group