The CreatorCon Call for Content is officially open! Get started here.

Report on Licensed users

madhuabbaraju
Kilo Contributor

Hello Everyone,

I'm trying to get a report for Licensed Users. By creating a report on sys_user table with below filter condition

sys id is javascript:gs.getRoledUsers();

The result gave me licensed users. But it includes the users who are having only role 'snc_internal'.

I want to exclude those users from the report. Please help on this.

Thanks

Madhuri

7 REPLIES 7

Dinesh Kumar7
Giga Contributor

Hello everyone,



I'm also having similar kind of requirement. please need help on this.


sajan0192
Giga Expert

Hope this will help you guys



1) create script include: snc_internal_users
2) set client callable = true.


3) set the filter condition in Report:   Sys ID IS NOT javascript:snc_internal_users()






function snc_internal_users() {



  var snc_role = false;


  var rpt_roles = [];


  var user = new GlideRecord("sys_user");


  user.query();


  while(user.next())


  {


  var user_role = new GlideRecord('sys_user_has_role');


  user_role.addQuery('user', user.sys_id);


  user_role.addQuery('role.name','snc_read_only'); //edit the role as per your requirement.


  user_role.query();


  while(user_role.next())


  {


  if(user_role.getRowCount() == 1)


  {


  rpt_roles.push(user.sys_id.toString());


  }


  }


  }


return rpt_roles;


}


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

If you got the Helsinki release I think you should look into the subscription management application:



Subscription Management application



//Göran