cancel
Showing results for 
Search instead for 
Did you mean: 

How to get groups of a user?

dabada83
Champ in-the-making
Champ in-the-making
Hey folks!,

I need to show some document only to people of certains documents.  I know that on doclist.get.js I want to control what items push or not,
based on groups of actual user.

How can I get list of groups of actual user???

Thanks!!!
3 REPLIES 3

analyzediz
Champ in-the-making
Champ in-the-making
Assuming you're making a webscript invocation, try the following:

/api/people/{username}?groups=true

Hope that helps

fast3r
Champ on-the-rise
Champ on-the-rise
I need this too!
Can you please be more specific on how to handle the json response from the remote call?
Is it just an array of shortName(s) of user groups?

One more question about groups, even if related to the Alfresco web client.
Is it possible to add by default in a freshly installed system a new user group (like SYSTEM_ADMINISTRATORS in Alfresco 3.0) and automatically add the 'admin' user?
Perhaps through a bootstrap xml file… but I really don't know which.

Thank you very much!

fast3r
Champ on-the-rise
Champ on-the-rise
I answer myself about the remote call, hope this helps.


   var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "?groups=true");
   if (result.status == 200 && result != "{}")
   {
      var users = eval('(' + result + ')');
     
      var groups = new Array();
      groups = users.groups;
      // do what you want with your array of group names
   }