Hi everybody, it will be appreciated if someone can help in, how to get the group for the current user in version 6.2 community.
Appreciate share the groovy script showing classes to import as I am not a java developer.
Thanks for your help, as I need to complete my project.
Nasser
1 Like
Hello,
you can find a Groovy script here below, that you can put as the Initial value on a text field of your form, for example.
import org.bonitasoft.engine.identity.UserMembership;
import org.bonitasoft.engine.identity.UserMembershipCriterion;
List listMemberships = apiAccessor.getIdentityAPI().getUserMemberships(loggedUserId, 0, 100, UserMembershipCriterion.ASSIGNED_DATE_ASC);
List listGroups = new ArrayList();
for (UserMembership userMembership : listMemberships){
listGroups.add(userMembership.getGroupName())
}
return listGroups.toArray().toString();
Note that a user can be member of more than one group, so you should create a list of groups that he belongs to. In this example, this list will be simply converted to String, but you can modify that based on your needs.
Hope this helps,
Haris
thanks a million Haris, yes it works good, your support is highly appriciated