ServiceNow License Counts

robertsteele
Kilo Explorer

We are using the Fuji release and attempting to get a license count of the different user roles in Service Now.   Does anyone know how I can get this information?

9 REPLIES 9

Mike Allen
Mega Sage

Counting Licensed Users - ServiceNow Wiki



To get specific number of users with each role, do this in a background script:



var user = new GlideRecord('sys_user');


user.addActiveQuery();


user.query();


var count = 0;


while(user.next()){



        var role = new GlideRecord('sys_user_has_role');


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


        role.addQuery('role.name', 'itil');


        role.query();


        if(role.hasNext()){


                  count++;


        }


}


gs.print(count);


Robert,


I have recently written a script that runs as a scheduled job to populate a user-defined field (u_type) to identify each user as one of the following:


  • Administrator
  • Approver
  • Fulfiller
  • Requester
  • Other

Selection_105.png


Selection_106.png


I have made the script available on my Google Drive for you to copy and paste into a scheduled job. Give it a try and let me know if you have any questions. All the script does is check user roles and update the user-defined field (u_type) in the sys_user table.



Cheers,


Jeff


Hello Jeff


Please ignore my last message regarding google drive availability.


It was a local proxy error at my building.


Apologies. Paul


Jeff Schodde
ServiceNow Employee
ServiceNow Employee

No worries. Let me know if you have any questions.