Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Google Group Settings with Google Apps Script

I have a Google Apps Script which has all the permissions it needs, with the Group Settings API on and working, but does not change certain things. There are no errors given, but the only thing that changes is the name, and the rest does nothing. This is the script:

function modgroup() {
  var groupKey = '[email protected]';

  var resource = {
   name: "finalfour", 
   whoCanContactOwner: "ALL_MEMBERS_CAN_CONTACT",
   whoCanJoin: "INVITED_CAN_JOIN", 
   whoCanViewMembership: "ALL_MEMBERS_CAN_VIEW", 
   whoCanViewGroup: "ALL_MEMBERS_CAN_VIEW",
   whoCanInvite: "ALL_MANAGERS_CAN_INVITE", 
   whoCanAdd: "ALL_MANAGERS_CAN_ADD", 
   allowExternalMembers: false,
   whoCanPostMessage: "ALL_MEMBERS_CAN_POST", 
   allowWebPosting: false 
  }

  AdminDirectory.Groups.update(resource, groupKey);

}
like image 412
Jason Jurotich Avatar asked Nov 25 '25 11:11

Jason Jurotich


1 Answers

Ok, after a bit of investigation and experimentation, I found that there was another API and another format that had to be used so that it will work. You need to activate the Groups Settings API (not the Admin Directory API) and you can see the documentation here.

The format is the following:

 function editGroup(){
    var groupId = '[email protected]';
    var group = AdminGroupsSettings.newGroups();
     group.name = 'NAME';
     group.description = 'DESCRIPTION';
     group.whoCanAdd = 'NONE_CAN_ADD';
     group.whoCanJoin = 'INVITED_CAN_JOIN';
     group.whoCanViewMembership = 'ALL_MEMBERS_CAN_VIEW';
     group.whoCanViewGroup = 'ALL_MEMBERS_CAN_VIEW';
     group.whoCanInvite = 'ALL_MANAGERS_CAN_INVITE';
     group.allowExternalMembers = false;
     group.whoCanPostMessage = 'ALL_MEMBERS_CAN_POST';
     group.allowWebPosting = true;
     group.showInGroupDirectory = false;
     group.allowGoogleCommunication = false;
     group.membersCanPostAsTheGroup = false;
     group.includeInGlobalAddressList = false;
     group.whoCanLeaveGroup = 'NONE_CAN_LEAVE';

   AdminGroupsSettings.Groups.patch(group, groupId);
 }
like image 80
Jason Jurotich Avatar answered Nov 26 '25 23:11

Jason Jurotich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!