Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Take name of a GROUP
I want take the name of a GROUP where a user or Admin belong.
EXAMPLE: Group(A;B;C;D)
User Nicolas belong to group named A, I want take value A;
I prove this way but not have a desired result because this is the id and i want the name:
User currentUser = PortalUtil.getUser(request);
currentUser.getGroup().getGroupId();
Lorenzo Leonori:I want take the name of a GROUP where a user or Admin belong.
EXAMPLE: Group(A;B;C;D)
User Nicolas belong to group named A, I want take value A;
I prove this way but not have a desired result because this is the id and i want the name:
User currentUser = PortalUtil.getUser(request);
currentUser.getGroup().getGroupId();
I'm assuming that you're looking for a UserGroup? Note that "Group" is the API name for Sites and similar collections of content - as the User API also has getGroup (like you stated), this is the user's personal group (read: site). I currently have no good option to look up the API, before my answer is slightly off: you'll need to look for the "UserGroup*" API, e.g. UserGroupLocalService or UserGroupService
-I'm assuming that you're looking for a UserGroup?
Yes it's UserGroup.
I prove this API UserGroupLocalService or UserGroupService but I don't get the name of group where user belong.
Example:
1- take a user e.g MARIO ROSSI
2- NAME GROUP USERS who mario belong is Administrative process, my result must be: Administrative process
Reguard to everyone.
Lorenzo Leonori:I prove this API UserGroupLocalService or UserGroupService but I don't get the name of group where user belong.
It sounds like you'll want to read the User
Groups section of the administrator guide in order to better
understand the difference between a Group and a
UserGroup. Essentially, you're calling
user.getGroup(), which returns an object representing the
user's personal site, which is not what you're looking for at all.
Given what you've stated, you want UserGroupLocalService.getUserUserGroups(long),
which provides a list of the user's UserGroup memberships.
List userGroups = userGroupLocalService.getUserUserGroups(user.getUserId());
for (UserGroup userGroup : userGroups) {
System.out.println(userGroup.getName());
}