小编kus*_*usi的帖子

使用 HtmlService 在 google apps 脚本中保存状态的位置

我有以下已发布的带有code.gs 的Web 应用程序

var queryString

function doGet(e) {
  queryString = e.queryString  

  //logger only works if the return value is commented out
  Logger.log(queryString)

  return HtmlService.createHtmlOutputFromFile('index.html')
}

function getQueryString() {
  // this prints "a=1" on the html
  // return "a=1"

  // this prints "undefined" on the html
  return queryString
}
Run Code Online (Sandbox Code Playgroud)

和index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <script>
      function onSuccess(queryString) {
        var div = document.getElementById('output');
        div.innerHTML = queryString;
      }
    </script>
  </head>
  <body>
    <button type="button" onclick="javascript:google.script.run.withSuccessHandler(onSuccess).getQueryString();">show query string</button>
    <div id="output"></div>
  </body> …
Run Code Online (Sandbox Code Playgroud)

javascript web-applications google-apps-script

7
推荐指数
1
解决办法
2424
查看次数

google script openById:您无权执行该操作

电子表格中的事件驱动脚本打开另一个电子表格

var ss = SpreadsheetApp.openById(otherSpreadsheetId); 
Run Code Online (Sandbox Code Playgroud)

查看执行记录,我收到以下错误

SpreadsheetApp.openById([0AjqSnE_p3nFqdDN0LWpFbjFqVDRwNmFGOV91QzZrZc]) [0 秒] 执行失败:您无权执行该操作。

当我直接在调试器中运行该函数时,我成功打开了另一个电子表格。当该函数由“onEdit”事件运行时,我收到错误。

我需要启用特定的 API 吗?

triggers google-sheets google-apps-script google-drive-api

3
推荐指数
1
解决办法
7149
查看次数