Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Grouping Assignment groups in an interactive filter

Elizabeth10
Tera Contributor

I need to create an interactive filter that has :

All Tech hub (list of 30 assignment groups)
2/3 level (list of 50 assignment groups)
ServiceDesk ( list of 6 groups)

I don't want the actual "list"  to be shown I just want to choose "all tech hub", "2/3 level" or "ServiceDesk" and the reports will update based on the groups contained in these.

How do I do that? I have tried with "group" and "cascading" but can't get it to work as I want

2 REPLIES 2

Bert_c1
Kilo Patron

@Elizabeth10,

 

Seems one Dynamic filter won't work for the 3 'parent' groups.  You will need one for each parent group. I've tested the following, where in my instance, the 'Database' group is the parent on 3 other groups. And the 'HR' group is the parent of 14 groups. A single Script include will work for each.  The definitions follow.

 

Dynamic Filter:

Screenshot 2025-05-16 144150.png

The script include:

Screenshot 2025-05-16 144629.png

The script contents:

var GetChildGroups = Class.create();
GetChildGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {

   initialize: function() {
    },

	getGroups : function(grpName) {
        var grpid = '';
		var grp = new GlideRecord('sys_user_group');
		grp.addQuery('name', grpName);
		grp.query();
		if (grp.next()) {
			grpid = grp.sys_id.toString();
		}

		var result=[];
		var childgrp = new GlideRecord('sys_user_group');
		childgrp.addQuery('parent', grpid);
		childgrp.query();
		gs.info("GetChildGroups: Found " + childgrp.getRowCount() + " child groups.");
		while (childgrp.next()) {
			result.push(childgrp.sys_id.toString());
		}
		gs.info('GetChildGroups: Returning: ' + result);
		return result;
    },

    type: 'GetChildGroups'
});

Assuming you've set the 'parent' group on each of the many child groups.

Thanks - at the moment we dont have the parent groups to group them on.
But certainly worth a try - maybe someone else needing this can give some feedback if it solved the issue for them 🙂