How to take a report who dont have itil role

shaik_irfan
Tera Guru

Hello,

I am facing difficulty in taking report of users who dont have itil roles,

Current functionality is we created a   group name ITIL and added the itil role to that group, when i assigned by default child roles related to itil are getting assigned to users, like if i add X user to ITIL group that user is getting itil, dependcy views, certification etc roles which is working fine. Now the problem is we have few users who are added manually to dependecy views roles who dont have itil role or not added to itil group we want that users report.

Please help me out to get the users who added manually with dependecy_views role and added to itil group

1 ACCEPTED SOLUTION

Related List Conditions come in with the new Report Designer which you can enable in Istanbul and is enabled by default in Jakarta.   In Helsinki, you have to do a little more work.



You can try a one-liner in the report.   This should give you all the users who have the itil role: [Note this must be in one line or it will not work.]



javascript:var users = []; var gra = new GlideAggregate('sys_user_has_role'); gra.addQuery('active', '=', true); gra.addQuery('role.name', '=', 'itil'); gra.groupBy('user'); gra.query(); while(gra.next()){users.push(gra.getValue('user'));} users;



You'll use this with something like (on the sys_user table):



sys_id IS <insert the script above>



One-liners like this (with a loop in it) no longer work in Jakarta but you have related list conditions at that point so you rarely need them.   If you still need this, you can put the logic in a script include and create a scripted filter or dynamic filter option.


View solution in original post

7 REPLIES 7

Adam Stout
ServiceNow Employee
ServiceNow Employee

Can you run a report on the sys_user table with a related list condition on User Role (sys_user_has_role)?


Adam,



We still using Helsinki and we dont see Related list option option


Related List Conditions come in with the new Report Designer which you can enable in Istanbul and is enabled by default in Jakarta.   In Helsinki, you have to do a little more work.



You can try a one-liner in the report.   This should give you all the users who have the itil role: [Note this must be in one line or it will not work.]



javascript:var users = []; var gra = new GlideAggregate('sys_user_has_role'); gra.addQuery('active', '=', true); gra.addQuery('role.name', '=', 'itil'); gra.groupBy('user'); gra.query(); while(gra.next()){users.push(gra.getValue('user'));} users;



You'll use this with something like (on the sys_user table):



sys_id IS <insert the script above>



One-liners like this (with a loop in it) no longer work in Jakarta but you have related list conditions at that point so you rarely need them.   If you still need this, you can put the logic in a script include and create a scripted filter or dynamic filter option.


Great that helped me. Thank you so much you helped my time