- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 01:24 PM
I would like to query the sys_user_group table to find all groups with certain roles but my script returns undefiled
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 02:31 PM
Maybe this is closer to what you are trying to do?
var grHasRole = new GlideRecord('sys_group_has_role');
grHasRole.addEncodedQuery('role.nameLIKEportfolio');
grHasRole.query();
while(grHasRole.next()) {
gs.print(grHasRole.group.name);
}
If you use only the 'role' field, you need to supply a sys_id. This example returns the group names of all having a role with portfolio in the name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 02:31 PM
Maybe this is closer to what you are trying to do?
var grHasRole = new GlideRecord('sys_group_has_role');
grHasRole.addEncodedQuery('role.nameLIKEportfolio');
grHasRole.query();
while(grHasRole.next()) {
gs.print(grHasRole.group.name);
}
If you use only the 'role' field, you need to supply a sys_id. This example returns the group names of all having a role with portfolio in the name.