Posts

Showing posts from November, 2017

Organization Administrator and Organization Owner

Image
In Liferay, we can assign the users to the Organization and can assign the Organization role to the users. There are 3 types of organization roles . After assigning the role ,  If we want to fetch the users who has the Organization administartor. Below is the code. long orgId = ParamUtil.getLong(request, "organizationId"); List<User> users = OrganizationUtil.getUsers(orgId); Group organizationGroup = OrganizationLocalServiceUtil.getOrganization(orgId).getGroup(); for(User user: users){   long organizationGroupId = organizationGroup.getGroupId();   if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(   user.getUserId(), organizationGroupId, RoleConstants.ORGANIZATION_ADMINISTRATOR)) {                   System.out.println("User is: "+ user);                                   } } First, we are fetching the users with Organizationid, Using that Organization, we are fetching the "Group" ,