Handling Groups and Subgroups

indukamaraj
Kilo Contributor

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.

17 REPLIES 17

I apologize for the typos.  They were all fixed above.  There was the assignment group typo, the missing semi colon and the quote in sys_idIN.

 

Please check the following.  Assigned To default and dependent value are BLANK

 

 

I knew something small would cause an issue that I just wasnt seeing.

There is a dictionary override on the incident table for assigned to. Didnt even cross my mind to look there. 

So after all that and doing the adjustments you just recommended, it works!

Sorry for making you go through all of that when it was mainly just small oversights. But i greatly appreciate your time and effort!

Here my attempt at getting rid of multiple `or` conditions. I'm doing multiple queries instead though.

 

var HierarchicalGroupMembershipUtils = Class.create();
HierarchicalGroupMembershipUtils.prototype = {
    initialize: function() {},

    getHierarchicalGroupMembership: function(groupId) {
        var groups = this.getChildrenGroups(groupId);

        var groupMemberships = new GlideAggregate('sys_user_grmember');
        groupMemberships.addQuery('group', 'IN', groups.join());
        groupMemberships.addAggregate('COUNT', 'user');
        groupMemberships.query();

        var groupUsers = [];
        while (groupMemberships.next()) {
            groupUsers.push(groupMemberships.user.toString());
        }

        return groupUsers;
    },

    getChildrenGroups: function(parentGroupId) {
        var processedGroupIds = {};
        processedGroupIds[parentGroupId] = true;
        this._getChildrenGroupsHelper(parentGroupId, processedGroupIds, 0);
        return Object.keys(processedGroupIds);
    },

    _getChildrenGroupsHelper: function(parentGroupId, processedGroupIds, depth) {
        if (depth > 50) {
            gs.error('Reached fallback depth. Ending lookup.');
            return;
        }

        var childGroupsGr = new GlideRecord('sys_user_group');
        childGroupsGr.addQuery('parent', parentGroupId);
        childGroupsGr.addActiveQuery();
        childGroupsGr.query();

        while (childGroupsGr.next()) {
            if (processedGroupIds[childGroupsGr.sys_id] !== true) {
                processedGroupIds[childGroupsGr.sys_id] = true;

                this._getChildrenGroupsHelper(childGroupsGr.sys_id, processedGroupIds, depth + 1);
            }
        }

        return;
    },

    type: 'HierarchicalGroupMembershipUtils'
};

 

And here is the `Advanced` Reference qualifier:

javascript:'sys_idIN'+(new global.HierarchicalGroupMembershipUtils().getHierarchicalGroupMembership(current.getValue('assignment_group')));