- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 10:05 AM
In one catalog item I have only assigned to variable and no assignment group variable .Assigned to variable is referencing to sys_user table .I have to display only one group members in assigned to variable.can any one provide the script to achieve this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 12:01 PM
Hi @sumanth1 ,
You just need to write a small script in the advance reference qualifier, no need of script include, paste this code in the advance reference qualifier:
javascript: var grpGR = new GlideRecord('sys_user_grmember');
grpGR.addQuery('group', " <your group's sys_id>");
grpGR.query();
var users='';
while(grpGR.next()){
users+=grpGR.user.sys_id + ",";
}
"sys_idIN" + users;
I used "ITSM-App Dev" group for testing:
If my answer has helped with your question, please mark it as helpful and accepted solution.
Thanks,
Karan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 11:03 AM
@sumanth1 Please use the following steps to implement this requirement.
1. Create a Script Include to provide filter for the Assigned_to reference field.
Here is how you will configure the script include.
We are going to use getUserFromGroup function from this script include to filter assigned_to list based on the group.
Here is the code for script include.
var MyUtilsV2 = Class.create();
MyUtilsV2.prototype = Object.extendsObject(AbstractAjaxProcessor, {
initialize: function() {},
myFunc:function(){
return 'hello';
},
getUsersFromGroup: function(groupName){
if(groupName){
var glideGrMember = new GlideRecord('sys_user_grmember');
glideGrMember.addEncodedQuery('group.name='+groupName);
glideGrMember.query();
var userArray = [];
while(glideGrMember.next()){
userArray.push(glideGrMember.getValue('user'));
}
return 'sys_idIN'+userArray.toString();
}
},
type: 'MyUtilsV2'
});
Now time to configure your variable on the catalog item.
This is how you should do it.
Here is the code for advanced qualifier.
javascript: new global.MyUtilsV2().getUsersFromGroup('ITSM App-Dev');
Here we are calling method getUsersFromGroup and passing the group name 'ITSM App-Dev'. You can change the group name on the basis of your current implementation.
This is how this functionality works.
The reference field only allows users to choose from the members of 'ITSM-App Dev' group.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 12:01 PM
Hi @sumanth1 ,
You just need to write a small script in the advance reference qualifier, no need of script include, paste this code in the advance reference qualifier:
javascript: var grpGR = new GlideRecord('sys_user_grmember');
grpGR.addQuery('group', " <your group's sys_id>");
grpGR.query();
var users='';
while(grpGR.next()){
users+=grpGR.user.sys_id + ",";
}
"sys_idIN" + users;
I used "ITSM-App Dev" group for testing:
If my answer has helped with your question, please mark it as helpful and accepted solution.
Thanks,
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 11:08 PM
Thanks Karan it worked for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2025 01:26 AM
Hi karan can you help me with the similar one i need to display the user where the user id contains "adm"