Handling Groups and Subgroups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2017 02:43 AM
I create a group (Group1) and add a user(user1) to group1 . Next I create a subgroup (subgroup1) and add parent as Group1 and add user2 to subgroup1. And assign roles to Group1 as "admin"
In the assigned group of Incident if I choose Group1 should user1 and user2 been displayed ie If i select the parent group should suggroups users also be displayed . In this case user1 and user2.
What is the concept here ? For me only the respective group users are getting displayed . Subgroup users are not getting displayed if i select the parent group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2017 09:39 AM
Hi Indumathui,
Nested groups (parent>child) can only be seen with the tree picker attribute turned on, the group structure is different than the user structure. Only the group selected will display the users within it. The group members do not roll up. Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2020 04:15 AM
So I was able to the "assigned to" to be populated by a group and all its sub groups using a script include. I borrowed pieces from the "getmygroup" functions update by ServiceNowguru. below is my script but note there are better ways to do the recursion vice me doing 5 levels of parent.parent I just havent taken the time to write it yet. Run as many addOrConditions group.parent.parent.sys_ids as you need for your nesting I actually run five which is embarrassing since really I should write it better.
script include - getMyMembershipsAdvanced
client Callable - true
assigned_to advanced reference qualifier : javascript:'sys_idIN'+getMyMembershipsAdvanced(current.getValue('assignement_group'));
I created the below script include then add the reference qualifier
function getMyMembershipsAdvanced(groupID){
///get sysId of assignment_group
var grpArr=[];
var gID = groupID;
//get all users in group and group parent
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('group.sys_id',gID).addOrCondition('group.parent.sys_id', gID).addOrCondition('group.parent.parent.sys_id', gID);
grmember.addQuery('group.active', true);
grmember.query();
while (grmember.next()){
grpArr.push(grmember.user.toString());
}
grpArr = checkDuplicates(grpArr);
return grpArr;
}
/// from SNguru line for line from here down!
function checkDuplicates(a){
//Check all values in the incoming array and eliminate any duplicates
var r = [];
o:for(var i = 0, n = a.length; i < n; i++){
for(var x = 0, y = r.length; x < y; x++){
if(r[x]==a[i]){
continue o;
}
}
r[r.length] = a[i];
}
return r;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2021 02:29 PM
Do you have an update on this? I'm trying to get it to work but I'm not great at scripting. I tried just copying it into a script includes but that didnt work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2021 04:41 AM
Its working as expected. Be sure you are adding things to the right places
client callable script include:
function getMyMembershipsAdvanced(groupID){
///get sysId of assignment_group
var grpArr=[];
var gID = groupID;
//get all users in group and group parent
var grmember = new GlideRecord('sys_user_grmember');
grmember.addQuery('group.sys_id',gID).addOrCondition('group.parent.sys_id', gID).addOrCondition('group.parent.parent.sys_id', gID);
grmember.addQuery('group.active', true);
grmember.query();
while (grmember.next()){
grpArr.push(grmember.user.toString());
}
grpArr = checkDuplicates(grpArr)
return grpArr;
}
/// from SNguru line for line from here down!
function checkDuplicates(a){
//Check all values in the incoming array and eliminate any duplicates
var r = [];
o:for(var i = 0, n = a.length; i < n; i++){
for(var x = 0, y = r.length; x < y; x++){
if(r[x]==a[i]){
continue o;
}
}
r[r.length] = a[i];
}
return r;
}
and the assigned to reference qualifier
assigned_to advanced reference qualifier : javascript:'sys_idIN"+getMyMembershipsAdvanced(current.getValue('assignment_group'));