The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Do isMemberOf() method works for Managers?

Vasu ch
Kilo Sage

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?

1 ACCEPTED SOLUTION

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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.

find_real_file.pngfind_real_file.png

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.

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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.

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader