2

我有一个 Google Apps 脚本,它具有所需的所有权限,组设置 API 已启用并正常工作,但不会更改某些内容。没有给出错误,但唯一改变的是名称,其余的什么都不做。这是脚本:

function modgroup() {
  var groupKey = 'finaltest@school.edu.mx';

  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);

}
4

1 回答 1

2

好的,经过一番调查和实验,我发现必须使用另一个 API 和另一种格式才能正常工作。您需要激活 Groups Settings API(不是 Admin Directory API),您可以在此处查看文档。

格式如下:

 function editGroup(){
    var groupId = 'finaltest@school.edu.mx';
    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);
 }
于 2018-07-25T14:27:44.220 回答