
- 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 05:25 AM
The notification is on table sys_user. I tried this code aswell but it doesnt seem to work for me. I think I have something set up wrong that is making the code always return false or always return true, regardless of the groups that users are in.
- 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-23-2022 12:37 AM
I am not quite sure why, but making the group name into a variable and then using it solved it! This works exactly as wanted!
Thank you for your help.