Foros de discusión

How to get count of users for specific role

thumbnail
Sadanand Ghadage, modificado hace 7 años.

How to get count of users for specific role

New Member Mensajes: 23 Fecha de incorporación: 26/12/14 Mensajes recientes
Hi Guys,

In my requirement, I have to calculate the number of users associated with a particular role in a site. Any pointers would be helpful..
I am using Liferay 6.2 CE GA5.
Thanks in advance.

Regards,
Sadanand
thumbnail
Pankaj Kathiriya, modificado hace 7 años.

RE: How to get count of users for specific role

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
You could use below API method to get user count for particular role based on roleId and status..

/**
	 * Returns the number of users with the status belonging to the role.
	 *
	 * @param  roleId the primary key of the role
	 * @param  status the workflow status
	 * @return the number of users with the status belonging to the role */
UserLocalServiceUtil.getRoleUsersCount(long roleId, int status)


Please note that Role can be assigned to Team, UserGroups etc; so I am not sure if above method returns that count too. You may investigate it further.
thumbnail
Sadanand Ghadage, modificado hace 7 años.

RE: How to get count of users for specific role

New Member Mensajes: 23 Fecha de incorporación: 26/12/14 Mensajes recientes
Thanks Pankaj for your reply.

But still no luck. I am getting '0' as a return value. Any other solution ?

Regards,
Sadanand
thumbnail
Pankaj Kathiriya, modificado hace 7 años.

RE: How to get count of users for specific role

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
Let us know what exact thing; you have tried? Also, give information on how Role is assigned to user.