which users are not in any one group and have a 'abcd' role, I have to create a report

harivas
Tera Contributor

which users are not in any one group and have a 'abcd' role, I have to create a report on those users so for this I have written script in script include and called in reports but Iam not getting proper result but through background scripts I got expected results. 
which I written the script is:

function testmon(){
  var grMember = new GlideRecord('sys_user_grmember');
        grMember.query();

 

        var groupMembers = [];
        while (grMember.next()) {
            groupMembers.push(grMember.user.toString());
        }

 

        var user = new GlideRecord('sys_user');
        user.addQuery('sys_id', 'NOT IN', groupMembers);
        user.addQuery('roles', 'abcd'); // Add condition to check if user has 'resource' role
        user.query();

 

        var nonGroupMembers = [];
        while(user.next()) {
            nonGroupMembers.push(user.name.toString());
        }

 

        return nonGroupMembers;

}

Please can any one help me on this query.

 

1 ACCEPTED SOLUTION

The script include looks good to me! However, I see you now have a typo in the method name when calling it in the filter condition and also the javascript needs to be lowercase. 

 

 

View solution in original post

8 REPLIES 8

Rene El Hamzh
Kilo Sage

Hi @harivas,

 

can you please show us how you've set up your report?

 

Best regards,

Rene

Hi @Rene El Hamzh 

 

I have created a report on 'sys_user' table and called a script from script include class name and function name please find attached screen shot for your reference, while running that script in backgrounds its working and getting the expected results which is which user not a part of any group and those have abcd role, Thank you!!!

Thank you! Sounds like your script include is not client callable. In order for it to work in filter conditions, you need to make it client callable. 

 

Best regards,

Rene

 

Please mark as correct/helpful if my answer helped you!

@Rene El Hamzh even I have checked that client callable as well is not working, is there any other suggestions please