Display Group Members of Child Groups

MGanon
Tera Guru

We have groups at 2 levels. Understanding that the group member tab shows the list of members of that group, we need to also display the members of children groups.

For example: Group C has members X, Y, & Z and is a child to group P. Group P has members A, B, & C. When a user opens group P, that user needs a related list showing the group C members. Ultimately, we would like a single list showing all member of the group and all children but a second tab showing just the children group members works for now.

Is this possible? If so, how?

Thanks

1 ACCEPTED SOLUTION

Nick Peters
Tera Guru

You can accomplish this by creating a new Relationship record and using it to query for group members of child groups.

Go to System Definition > Relationships and create a new record.

Name:
Child Group Members->Parent Group

Applies to table:
Group [sys_user_group]

Queries from table:
Group Member [sys_user_grmember]

Query with:

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);
	current.addQuery('group.parent', parent.sys_id);

})(current, parent);

Go to a group record, open the context menu, and go to Configure > Related Lists. Select the relationship record you just made. That's it! You may want to rename the related list on the form to give it a better name.

View solution in original post

13 REPLIES 13

Good Afternoon, this is great and I've followed the instructions and it has pulled accross the Child group members on the group form view. 

my only problem now is that we need the child group members pulling to the "group members" tab so that tickets can be assigned to them directly.

Steps ive completed:

1) Created a parent group called "Infrastructure - Parent"

2) Linked two child groups to the parent (Infrastructure-1 AND Infrastructure-2)

3) I have created a new relationship within SN to display "Child Group Members" on the parent group view with the coding above

4) I have then navigated back to the parent group and i have added in "child group members" in the related lists so that it is visible from the group form view - which is working great

5) I have then opened an incident form, amended the Assignment Group dictionary with the filter "parent is empty" (the idea is that it wont display any group that is not a parent group) - the filter is working as expected and now only shows the "Infrastructure - Parent" group. My issue is that when i then click on the "Assigned to" ref, its not pulling through the Child group members like we need it to.

Please can you advise. I can see that the users haven't been pulled onto the Members tab within the group view - i think this is the issue. Is there some logic we can input into the system to pull the members across? thank you

ToniOxley
Kilo Expert

Good Afternoon, this is great and I've followed the instructions and it has pulled accross the Child group members on the group form view. 

my only problem now is that we need the child group members pulling to the "group members" tab so that tickets can be assigned to them directly.

Steps ive completed:

1) Created a parent group called "Infrastructure - Parent"

2) Linked two child groups to the parent (Infrastructure-1 AND Infrastructure-2)

3) I have created a new relationship within SN to display "Child Group Members" on the parent group view with the coding above

4) I have then navigated back to the parent group and i have added in "child group members" in the related lists so that it is visible from the group form view - which is working great

5) I have then opened an incident form, amended the Assignment Group dictionary with the filter "parent is empty" (the idea is that it wont display any group that is not a parent group) - the filter is working as expected and now only shows the "Infrastructure - Parent" group. My issue is that when i then click on the "Assigned to" ref, its not pulling through the Child group members like we need it to.

Please can you advise. I can see that the users haven't been pulled onto the Members tab within the group view - i think this is the issue. Is there some logic we can input into the system to pull the members across? thank you

Are you looking at the related list for the Group Members or for a subordinate related list for Child Group Members? The Group Members related lists will only display 1 level.

I was able to do this using a script include and reference qualifer.. you can find it here: Handling Groups and Subgroups - Developer Community - Question - ServiceNow Community

Did you ever find a solution for this? I'm looking to do the same thing with on-call roster.