- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 06:46 AM
Hello community! First time crying for help!
I am working on a service catalog item.
I am trying to use a script include and catalog client script (posted below, adapted from one I found here) and it's not working.
My use case is, the end user selects a user from a reference select box, that pre-populates the owner_asg select box only with groups that user is a member of.
The end user can change the user and the owner_asg box should change available groups to the new users groups.
I'm open to other solutions but thought the script include was the way to go. Any help is appreciated.
Catalog Client Script:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 02:03 PM
@Jason Thornton Here is the solution we finally concluded.
var GroupsMembership = Class.create();
GroupsMembership.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getGroups: function(record) {
gs.info('in script')
var groups = [];
var user = this.getParameter('sysparm_userID');
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', record);
gr.addQuery('group.name','STARTSWITH','ASG');
gr.query();
while (gr.next()) {
groups.push(gr.group.sys_id);
gs.info(gr.group.sys_id)
}
gs.info("record is" + record);
return 'sys_idIN'+groups.toString();
},
type: 'GroupsMembership'
});
GroupsMembership.get = function() {
return new GroupsMembership();
};
Here is the reference qualifier.
//Variable Reference Qualifer Script
javascript: x_scopapp_utils.GroupsMembership.get().getGroups(current.variables.user);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 06:58 AM
@Jason Thornton Could you please update the getResults as follows.
function getResults(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
var answerArray = answer.split(',');
for(var i=0; i<answerArray.length;i++){
g_form.addOption('owner_asg',answerArray[i],answerArray[i]); // Assuming owner_asg is a select box which shows group names.
}
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 07:22 AM
That still brings back ALL groups. I'm not sure what I'm missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 07:30 AM
My user variable name is 'crep_owner' in the catalog item. Does that make a difference in my script include?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 07:36 AM
@Jason Thornton Found a typo at line groups.push(gr.groups.getDisplayValue()); in script include.
Please update your script include script as follows.
var GroupsMembership = Class.create();
GroupsMembership.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function() {
var groups = [];
var user = this.getParameter('sysparm_userID');
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user);
gr.query();
while (gr.next()) {
groups.push(gr.group.getDisplayValue());
}
return groups.toString();
},
type: 'GroupsMembership'
});
Hope this helps.