Home > Software design >  How to add people to google groups programmatically using google app script?
How to add people to google groups programmatically using google app script?

Time:04-14


  var form = FormApp.openById('1IErsge8yafg0UOltvhecAMhRd5Yh1VXJdhkI');
  var groupID = "[email protected]";

  var formResponses = form.getResponses();
  for (var i = 0; i < formResponses.length; i  ) {
    var formResponse = formResponses[i];
    var itemResponses = formResponse.getItemResponses();
    var email = itemResponses[1].getResponse();
    Logger.log(email);
    var newMember = {email: email, role: "MEMBER"};
    AdminDirectory.Members.insert(newMember, groupID);
  }

}

This is the code I've written and I'm getting an error enter image description here

After some research I found out that the error is because I don't have a G Suite subscription.

However, I am not able to find anything about how achieve the same task without a G Suite subscription. Can anyone please help me with that?

Thanks in advance!

CodePudding user response:

As you aren't Google Workspace Admin, please checkout the Jay Lee's answer to Google Groups API add Member. Tl;Dr: AdminDirectory can be used only by Google Workspace Admins.

You might try to use the Groups Service to get information about a Google Group but it hasn't a method to add users to a group, so your only options are to add the users manually or to use web-browser automation tool.

Resources

Related

  • Related