0

I want to go through all the Google groups I am a member of and get the list of all the users of each group :

var list = GroupsApp.getGroups();

for(var i = 0; i< list.length; i++){ 

  for(var key in headerObj){

         var text = "";

         if(key == "users"){

            var tab = list[i].getUsers();

            if(tab.length > 0){ 

             text = tab[0].getEmail();

             for(var j = 1; j < tab.length; j++){

              text += ", " + tab[j].getEmail();
             }
            } 
            headerObj[key].push(text);
            }
          }
        }

But I always get this Exception :

You do not have permission to view the member list for the group: "group email"

Is there a way to go through all the Google groups of which, I am the administrator ?

Bayrem Ben Alaya
  • 297
  • 1
  • 3
  • 16

1 Answers1

1

Unfortunatly such a thing is not possible there is however the workaround of a try catch:

function myFunction() {
  var allGroups = GroupsApp.getGroups();
  for (var i in allGroups){
    try { 
      var users = allGroups[i].getUsers();
      for (var j in users){
        Logger.log(users[j]); 
      }
        } 
    catch (e) { }
  }
}
Thomas
  • 569
  • 3
  • 10