isMemberOf not working in notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Requirement is not sending a notification in case approver is part of specific group. Please find the code I used in notification advanced condition which is not working it seems. Even if approver part of group mentioned, it is sending the notification. Notification is on Approval[sysapproval_approver] table.
script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
ahoy @VuchiV,
I checked and the isMemberOf() seems to necessarily require connection with gs.getUser() as it is returning logged-in user. If you use dot walking as "current.approver..." it doesn't do the trick or it must be written differently.
Tested in my PDI
- Lines 1 to 8 are having hardcoded sys id and return "2" saying that this sys Id is not a member of that group,
- Lines 10 to 15 have the gs.getUser()
Try to extend this for the sys_approver logics..
var myID = new GlideRecord("sys_user");
if (myID.get("your_sys_ID"))
gs.print('myID: ' + myID.sys_id);
if (myID.isMemberOf('group_sys_ID')) {
gs.print('myID is a member');
} else {
gs.print('myID is NOT a member');
}
gs.print('gs.getUserID: ' + gs.getUserID());
if (gs.getUser().isMemberOf('group_sys_ID')) {
gs.print('getUserID is a member');
} else {
gs.print('getUserID NOT a member');
}
Answers generated by GlideFather. Check for accuracy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @VuchiV
Seems like a duplicate to an active thread created by you: https://www.servicenow.com/community/itsm-forum/ismemberof-not-working-in-notification/td-p/3540689
You can find my response in above thread.
Hope that helps!