- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 02:44 AM
Hi,
I've a requirement to check if the loggedin user is member or manager for a group or not. For this is used gs.getUserId().isMemberOf('my group') method. Its working for the group members. But when manager logs in its not working. But I read somewhere in community that this method works for managers too. Is it right? Or Are there any further things I should do?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 03:15 AM
Hi,
the issue is coming because Luke Wilson who is group manager is not group member
In that case you need to query Group table and get manager and then check in sys_user_grmember table if that user is member or not
There is no direct way for this
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 02:58 AM
Hi,
Can you share complete script?
Are you saying you want to check if logged in user's manager is group member or not?
This line will check if logged in user's manager is member of the group or not
gs.getUser().getUserByID(gs.getUser().getManagerID()).isMemberOf('my group');
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 03:03 AM
Hi Ankur,
I've a group Test 3 and I want to check if currently loggedin user is the manager of that group or not.
Now, if Luke wilson logs in then I want my isGroupMember function in the above script to return true because Luke wilson is the manager for Test 3 group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 03:15 AM
Hi,
the issue is coming because Luke Wilson who is group manager is not group member
In that case you need to query Group table and get manager and then check in sys_user_grmember table if that user is member or not
There is no direct way for this
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 03:21 AM
Thank you Ankur. I read somewhere in community itself that isMemberOf() method also returns true for group managers. That's why I opened this thread. Thanks for the clarification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 03:30 AM
Hi,
As per my understanding it would work only when group manager is group member
If my response helped please mark it helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader