Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Script Include for reference qualifier, for showing groups with atleast one member

AadityaSahu
Tera Contributor

Hello Community

 

The requirement is that I need to create Reference Type Variable and this variable should display Groups from the sys_user_group Table.

But it has 3 conditions :

1. It should ONLY display Active Groups

2. It should ONLY display Groups of XYZ Company

3. It should ONLY display Group members with ATLEAST one member

 

I want to create a Script Include. And want to use this Script Include as Advance Qualifier for this Reference Variable.

I created a Script but it is not Working at all.

 

Hope you guys would be able to point out what is wrong with the following Script

 

var ActiveGroupsWithMembers = Class.create();
ActiveGroupsWithMembers.prototype = Object.extendsObject(AbstractAjaxProcessor,
{
    getActiveUsersGroups: function()
    {
        function getActiveUsersGroups()
        {
        var GroupIfMember = [];
        var usr = new GlideRecord("sys_user_grmember");
        usr.addEncodedQuery("sys_domain=sysID__of__XYZ__Company^group.active=true");
        usr.query();
        while(usr.next())
        {
        GroupIfMember.push(usr.group.sys_id);
        }
        return 'sys_idIN' + GroupIfMember;
        }
    },
    type: 'ActiveGroupsWithMembers'
});
5 REPLIES 5

@AadityaSahu 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader