Fórum

RE: Getting 'null' while i retrieve the list of users in a Group - Liferay

praveen orvakanti, modificado 12 Anos atrás.

Getting 'null' while i retrieve the list of users in a Group - Liferay 6API

Junior Member Postagens: 51 Data de Entrada: 10/08/11 Postagens Recentes
Hi All,
I'm trying to retrieve the list of users belonging to a Group. I'm using Liferay 6.0.5 API. The following are the different API i used to retrieve the list of users in a Group:
>>>> long[] userIds = UserServiceHttp.getGroupUserIds(httpPrincipal, groupCollabId);
>>>> List<com.liferay.portal.model.User> users = UserLocalServiceUtil.getGroupUsers(groupId);

I have double checked and verified the groupId. Is there something that I'm missing?

Thanks,
Ronnie
thumbnail
Amos Fong, modificado 12 Anos atrás.

RE: Getting 'null' while i retrieve the list of users in a Group - Liferay

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
This looks correct. However, when you say belonging to a "group", do you specifically mean a community? Because there are other methods for different entities (which have a corresponding "group") like organizations and usergroups. Maybe this is the method you want? This is a UserGroup which is different from Group.

UserLocalServiceUtil.getUserGroupUsers(long userGroupId)
praveen orvakanti, modificado 12 Anos atrás.

RE: Getting 'null' while i retrieve the list of users in a Group - Liferay

Junior Member Postagens: 51 Data de Entrada: 10/08/11 Postagens Recentes
Hi Amos,
Thx for the reply.

I'm not looking in a particular 'UserGroup'. I have a portal Instance 'ABC'. Inside that poratal instance, i have a created a couple of Organizations, lets say, 'ABC1' and 'ABC2'. I have aalso created a bunch of users.

Now i want to get the list of users that are part of the group 'ABC1'. How do i get it?

Thanks & Regards
thumbnail
Mahendra Mahakle, modificado 12 Anos atrás.

RE: Getting 'null' while i retrieve the list of users in a Group - Liferay

Junior Member Postagens: 80 Data de Entrada: 14/03/11 Postagens Recentes
Hi Praveen,
If you have organization ABC1 "groupId" then you can use following method to get the list of user(s) from ABC1.

UserLocalServiceUtil.getOrganizationUsers(GroupLocalServiceUtil.getGroup(groupId).getOrganizationId());

OR
If you have only "groupId" and you don't know it's user group or Organization group then you can use following code....
List<User> users=null;
if(GroupLocalServiceUtil.getGroup(groupId).isOrganization())
{
users= UserLocalServiceUtil.getOrganizationUsers(GroupLocalServiceUtil.getGroup(groupId).getOrganizationId());
}
else if(GroupLocalServiceUtil.getGroup(groupId).isUser())
{
users=UserLocalServiceUtil.getUserGroupUsers(groupId);
}
praveen orvakanti, modificado 12 Anos atrás.

RE: Getting 'null' while i retrieve the list of users in a Group - Liferay

Junior Member Postagens: 51 Data de Entrada: 10/08/11 Postagens Recentes
Thx a lot Mahendra,
That worked emoticon