AnsweredAssumed Answered

Javascript list members of groups

Question asked by patrickvanhoof on Jan 28, 2019
Latest reply on Jan 30, 2019 by roberto.gamiz

Hi,

 

I have following code to list members of Alfresco groups:

var siteGroups = new Object(); 
var logFile = space.childByNamePath("GroupAndUsers.txt");

if (logFile == null)
{
     logFile = space.createFile("GroupAndUsers.txt");
}

// return all results, skip 0
var paging = utils.createPaging(-1, 0);

siteGroups = groups.getGroups(null, paging);

for (var i=0; i<siteGroups.length; i++)
{
     if (siteGroups[i].displayName.indexOf("gl_aa_alfresco_") == -1 &&
          siteGroups[i].displayName.indexOf("gl_center_") == -1 &&
          siteGroups[i].displayName.indexOf("site_") == -1)
     {
          
          logFile.content += siteGroups[i].displayName + "\n";
     
          var group = people.getGroup(siteGroups[i].id);
          var members = people.getMembers(group,false);
          
          for (var member in members)
          {
               logFile.content += member.properties.userName + "\n";
          }
     }
}

logFile.save();
logFile.content; 12345678910111213141516171819202122232425262728293031323334

But line

  var members = people.getMembers(group,false);

gives an error. What is wrong?

 

Using Alfresco 5.0.3.

 

Thanks,

Patrick

Outcomes