- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2025 07:34 AM
Hi all,
I am using getMyGroups() in my code to get all groups. It is returning one extra group. Why?
I know below thing can be achieved by other ways, but I want to use getMyGroups().
My code-
*** Script: Name HR Tier 1
*** Script: Name App Engine Admins
*** Script: Name Conditional Script Writer
*** Script: Name Team Development Code Reviewers
*** Script: Name HR
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2025 10:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2025 07:37 AM
All these groups don't have Parent except HR Tier 1 , it is a child of HR group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2025 07:51 AM
getMyGroups() returns parent group as well for the child to which you belong
So you should query sys_user_grmember to get exact group to which you belong
var groups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', 'IN', gs.getUserID());
gr.query();
while (gr.next()) {
groups.push(gr.group.name.toString());
}
gs.info('groups are' + groups.toString());
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2025 06:58 PM
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2025 10:18 PM
Hi @Ankur Bawiskar ,
I never found anywhere that states it will return parent group as well for the child to which you belong. Please mention any doc or article links you know.
Thanks for Gliderecording group solution , but I want to know about getMyGroups() functionality.
