AnsweredAssumed Answered

Iterate members of a site

Question asked by patrickvanhoof on Oct 26, 2017

Hi,

 

I use following script:

 

var sites = new Array();
var members = new Object();

var logFile = space.childByNamePath("log.txt");
if (logFile == null)
{
   logFile = space.createFile("log.txt");
}

var log = "";

function main() {

 sites = siteService.listSites(null, null);
 
 for (i=0; i<sites.length; i++)
 {
  if (sites[i].title == "Patricks")
  {
   log = sites[i].title + "\n";
   logFile.content += log;
   
   members = sites[i].listMembers(null, null, 0, false);

   for (var userName in members)
   {
    var user = people.getPerson(userName);
    var email = user.properties["cm:email"];
    log = userName + ";" + members[userName] + ";" + email + "\n";
    logFile.content += log;
   }
  }
 }
}

main();

 

What is logged is 10 times the users of the site Patricks. Why is this? I tried with members = sites[i].listMembers(null, null, 0, true); but that gives the same result.

 

Thanks,

Patrick

Outcomes