使用Google Apps脚本将编辑者添加到Google文档中 [英] Adding Editors to a Google Document with Google Apps Script

查看:63
本文介绍了使用Google Apps脚本将编辑者添加到Google文档中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Apps脚本将编辑者和查看者添加到Google文档中. addEditors()的文档说:

I'm trying to add editors and viewers to a Google Doc using Google Apps Script. The documentation of addEditors() says that:

将给定的用户数组添加到文档的编辑器列表中.

Adds the given array of users to the list of editors for the Document.

我不知道如何为此配置或使用阵列.数组由从其他脚本文件传递的值确定.

I can't figure out how to configure or use an array for this. The array is determined by values passed from a different script file.

推荐答案

好,没有任何代码开头,您需要执行以下操作:

Well, without any code to start with you need to do something like the following:

function addEditors() {
  var emails = [
    'john@example.com',
    'steve@example.com',
    'bill@example.com'
  ];

  DocumentApp.getActiveDocument().addEditors(emails);
}

数组是Javascript中的变量类型,您需要了解数组才能开始使用Apps脚本.

Arrays are a variable type in Javascript that you need to know to get started with Apps Script.

您可以在此处了解有关数组的更多信息: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array

You can read more about arrays here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

或者在FreeCodeCamp上进行一些练习:

Or get some practice at FreeCodeCamp: https://www.freecodecamp.com/challenges/store-multiple-values-in-one-variable-using-javascript-arrays

祝你好运.

这篇关于使用Google Apps脚本将编辑者添加到Google文档中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆