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

michelleatx
Kilo Explorer

There is actually a way to do this without using Report Designer. You just need to create a List Report on the User Role [sys_user_has_role] table with a Filter on the User Related Field of 'Roles' 'is not' 'itil'. Aka you'll need to dot walking from User==>User Fields to Roles on the filter. This should get you what you need.


FILTER ON ITIL.PNG


FILTER ON ITIL 2.PNG


I didn't know the roles field existed until now.   Before you report on it, validate it is being populated on your instance.   I just look at an OOTB instance and see htat some demo users have roles set but when I manually added the itil role to a user, it did not change the user.role field and I don't see a BR on sys_user_has_role that populated it.   If that data looks good on your instance, this seems like a good solution, just be sure to validate a few of the results manually.   This may be a deprecated or unsupported field.


We had it in Geneva and Helsinki and now in Jakarta... and it's still being updated.   The role field in the above isn't user.role (sys_user) it's on user roles (sys_user_has_role). There is an entry in that table for everyone of our users and their roles.. inherited or not.   This function is related to this plugin in believe



Contextual Security Manager