- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 06:04 AM
I have created a script include to return the group of current logged in user.
Its returning fine when i checked in background script.
and added the above script include in dynamic filter option and configured it in dictionary for Caller reference field but still it returns all the users instead of group members only.
Script Include:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 08:10 AM
You can try gs.getUserID() instead of the other method in your addQuery. Add a log of this value to confirm which way (or both) works. Since you will have the current user's sys_id, you don't need two GlideRecords, and you'll want to push the USER SYSIDs to an array, not a group name since it sounds like you want to select user(s), not groups. So it will look more like this:
getGroup:function(){
var user = gs.getUser().getID();
gs.info('Dynamic RQ getUser method = ' + user);
user = gs.getUserID();
gs.info('Dynamic RQ getUserID method = ' + user);
var usersArr = [];
var groups=new GlideRecord('sys_user_grmember');
groups.addQuery('user', user);
groups.query();
while (groups.next()) {
usersArr.push(groups.user.toString());
}
return usersArr.join(',');
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 08:10 AM
You can try gs.getUserID() instead of the other method in your addQuery. Add a log of this value to confirm which way (or both) works. Since you will have the current user's sys_id, you don't need two GlideRecords, and you'll want to push the USER SYSIDs to an array, not a group name since it sounds like you want to select user(s), not groups. So it will look more like this:
getGroup:function(){
var user = gs.getUser().getID();
gs.info('Dynamic RQ getUser method = ' + user);
user = gs.getUserID();
gs.info('Dynamic RQ getUserID method = ' + user);
var usersArr = [];
var groups=new GlideRecord('sys_user_grmember');
groups.addQuery('user', user);
groups.query();
while (groups.next()) {
usersArr.push(groups.user.toString());
}
return usersArr.join(',');
},