
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 02:40 PM
Hi. I need to present a variable in a request form for a Catalog Item that allows the requester to select one of their manager's assignment groups from sys_user_group.
How can I create a reference qualifier on the variable so that only the requester's manager's groups are available as options?
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 09:24 AM
Ok so what you can try to do in the original script is add the following line to get your support groups.
gr.addQuery('group.type', 'CONTAINS','eb6c00b0db3700507e99e855ca9619b5'); //this needs to be the sys_id of the group type you want

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 10:15 AM
Hi, Bryan. Thank you. This script is working and showing the groups that the manger manages. After seeing the results, I've determined that I will need to use the groups that the user's manager is a member of, instead of groups that they manage. For example, one user's manager is a member of 5 visible support groups, but only a manager for one. With the current script, only one group is returned.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 09:24 AM
Ok so what you can try to do in the original script is add the following line to get your support groups.
gr.addQuery('group.type', 'CONTAINS','eb6c00b0db3700507e99e855ca9619b5'); //this needs to be the sys_id of the group type you want

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 02:09 PM
@Brian Lancaster @Alka_Chaudhary Thank you both for the help. It's working great.
Here's the details of the working build:
Reference qualifiers:
Manager's groups
javascript: new getRequestedForDetails().getReqManagerGroup(gs.getUserID());
User's groups
javascript: new getRequestedForDetails().getReqUserGroups(gs.getUserID());
Script Include: getRequestedForDetails
var getRequestedForDetails = Class.create();
getRequestedForDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getReqManagerGroup: function(userid) {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', userid);
user.query();
if (user.next()) {
var arrGroup = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user.manager);
gr.addQuery('group.type', 'CONTAINS', 'f429f94c0a0a3c9801ecd71fa6749366'); //sys_id of the group type: support
gr.query();
while (gr.next()) {
arrGroup.push(gr.group.toString());
}
}
return 'sys_idIN' + arrGroup;
},
getReqUserGroups: function(userid) {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', userid);
user.query();
if (user.next()) {
var arrGroup = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user.sys_id); // Changed from user.manager to user.sys_id
gr.addQuery('group.type', 'CONTAINS', 'f429f94c0a0a3c9801ecd71fa6749366'); //sys_id of the group type: support
gr.query();
while (gr.next()) {
arrGroup.push(gr.group.toString());
}
return 'sys_idIN' + arrGroup;
} else {
return []; // Return an empty array if user is not found
}
},
type: 'getRequestedForDetails'
});