如何使用谷歌应用程序脚本更新谷歌群组设置



我有一个Google应用程序脚本,它拥有所需的所有权限,组设置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);
}

好吧,经过一番调查和实验,我发现还有另一种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);
}

相关内容

  • 没有找到相关文章

最新更新