- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 09:11 AM
- User Selection: The form allows selection of multiple users.
- Group Filtering: Based on the selected users, the Group field should dynamically filter and show only the groups that are common to all selected users.
- Validation Logic: This ensures that users are not removed from groups they are not part of, avoiding errors.
Script Include:
var getCommonGroups = Class.create();
getCommonGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCommonGroups: function(userList) {
gs.info("PRITHVI: Starting getCommonGroups with userList = " + userList);
var users = userList.split(',');
var groupCount = {};
var commonGroups = [];
for (var i = 0; i < users.length; i++) {
gs.info("PRITHVI: Checking groups for user = " + users[i]);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', users[i]);
gr.query();
while (gr.next()) {
var groupId = gr.group.toString();
gs.info("PRITHVI: Found group = " + groupId + " for user = " + users[i]);
groupCount[groupId] = (groupCount[groupId] || 0) + 1;
}
}
for (groupId in groupCount) {
gs.info("PRITHVI: Group " + groupId + " has count = " + groupCount[groupId]);
if (groupCount[groupId] == users.length) {
commonGroups.push(groupId);
gs.info("PRITHVI: Group " + groupId + " is common to all users");
}
}
var result = commonGroups.join(',');
gs.info("PRITHVI: Returning common groups = " + result);
return result;
},
type: 'getCommonGroups'
});
Reference Qualifier:
javascript: 'sys_idIN' + getCommonGroups(current.variables.requestor);
Issue: Wfter selecting the user even though is part of the group the list does not show any groups and even the logs is empty.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 09:20 AM
javascript: 'sys_idIN' + new getCommonGroups().getCommonGroups(current.variables.requestor);
,
update the ref qual as this
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 09:20 AM
javascript: 'sys_idIN' + new getCommonGroups().getCommonGroups(current.variables.requestor);
,
update the ref qual as this
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 09:28 AM
Hello @Chaitanya ILCR ,
I tried updating the reference qualifier using:
javascript: 'sys_idIN' + new getCommonGroups().getCommonGroups(current.variables.requestor);
Unfortunately, it didn’t work as expected. The field didn’t filter correctly based on the common groups. Let me know if there’s a different approach we should try or if any adjustments are needed in the script.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 09:40 AM
Working after i made the changes as per the below line -
javascript: 'sys_idIN' + new getCommonGroups().getCommonGroups(current.variables.requestor);