【问题标题】:Adding Editors to a Google Document with Google Apps Script使用 Google Apps 脚本将编辑器添加到 Google 文档
【发布时间】:2017-05-11 02:03:39
【问题描述】:

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

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

我不知道如何为此配置或使用数组。该数组由从不同脚本文件传递的值确定。

【问题讨论】:

    标签: arrays google-apps-script


    【解决方案1】:

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

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

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

    您可以在此处阅读有关数组的更多信息:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

    或在 FreeCodeCamp 练习一下:https://www.freecodecamp.com/challenges/store-multiple-values-in-one-variable-using-javascript-arrays

    祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      相关资源
      最近更新 更多