Get total number of users with itil license
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 09:49 AM
Hi
For a special catalog item only available some certain users I want/need to display to total number of active users in a group that already have itil licenses.
We have users in multiple groups so show in the sys_user_has_role table shows the user multiple times. So how could I get a total number for the users. I can't seem to get that work. I know the count should be 115 but I get 240.
I am getting this via a client script triggering a script include:
var usercount = Class.create();
usercount.prototype = Object.extendsObject(AbstractAjaxProcessor, {
aggregate: function() {
var getcount = new GlideAggregate('sys_user_has_role');
// getcount.groupBy('user'); // THIS RETURNS 'NULL'
getcount.addQuery('role.name','itil');
getcount.addQuery('user.company.name','STARTSWITH','<company_name>');
getcount.addQuery
getcount.query();
while (getcount.next())
{
var users =getcount.user;
var license =getcount.getAggregate("COUNT", users);
gs.log("Users count ==" + license);
}
return license;
},
});
I also tried replacing getcount.addAggregate("COUNT"); AND getcount.getAggregate("COUNT", users); with getfjscount.addAggregate("COUNT(DISTINCT)","user"); but that NULL's
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2020 11:13 PM
Hey Team
Any luck here? am also trying to find the total number of unique users count who has ITIL role returned to a variable.
REgards
Ran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2020 10:27 PM
Hi,
Any idea how to restrict ITIL license not be added anymore if counts exceed certain number for itil license.. Want to restrict on Group form and user form too so that its throws errors if unique counts exceed the certain counts for itil..