cancel
Showing results for 
Search instead for 
Did you mean: 

Get group name of current user

jenn_l
Champ on-the-rise
Champ on-the-rise
Hoi all,

How can i get the group name of the current logged on user where this user belongs to Using Javascript?

Thanks,
Jenny
3 REPLIES 3

jenn_l
Champ on-the-rise
Champ on-the-rise
Hoi there!

I have figured it out! I 'd like to share it with you.
Here's the syntax:

//FIND THE GROUPNAME OF THE CURRENT LOGGED ON USER
   
   var currentUserName = person.properties.userName;
   
   var currentPerson = people.getPerson(currentUserName);
   
   var groupNameCurrentUser = people.getContainerGroups(currentPerson);

sgartner
Champ on-the-rise
Champ on-the-rise
//FIND THE GROUPNAME OF THE CURRENT LOGGED ON USER
   var currentUserName = person.properties.userName;
   var currentPerson = people.getPerson(currentUserName);
   var groupNameCurrentUser = people.getContainerGroups(currentPerson);

You're going to a bit more trouble there than you need to.  The object you are getting back from getPerson is identical to the object you are using to get the original userName.  This code works just as well for me:

var currentUsersGroups = people.getContainerGroups(person);

nwali
Star Contributor
Star Contributor

Hey
I used the method mentioned in your comment and I'm getting below result.

Current groups::Node Type: {http://www.alfresco.org/model/content/1.0}authorityContainer, Node Aspects: [{http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]

and not showing the group user is in like GROUP_TEST and GROUP_ALFRESCO_ADMINISTRATORS

Do you have any idea which method should I use to get groups of user??