【发布时间】:2019-02-01 04:01:02
【问题描述】:
我运行 doGet() 函数。它在电子表格上创建一个模式对话框。它将显示一个“关闭”和“制作复制”按钮,后者将在其中运行一个服务器端函数 doSomething(),该函数制作一个模板的副本。无论我是将函数附加到按钮还是直接在脚本标签中运行,它都拒绝运行。无论如何要修复或至少调试这个?
代码.gs
function doGet() {
return SpreadsheetApp.getUi().showModalDialog(HtmlService.createHtmlOutputFromFile('Index'), 'Report');
}
function doSomething() {
var file = template.makeCopy();
file.setName('NEW FILE NAME')
google.script.host.close()
}
Index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
google.script.run.doSomething()
</script>
</head>
<body>
<input type="button" value="Close" onclick="google.script.host.close()"/>
<input type="button" value="Make Copy" onclick="google.script.run.doSomething();" />
</body>
</html>
【问题讨论】:
-
我不确定
templatevarialbe 在您的情况下是否可以是全局的。我觉得@tehhowch 也指出了一件好事 -
检查 Stackdriver 是否存在未处理的异常。请注意,doGet 是用于访问已发布 web 应用程序的触发器,而不是侧边栏,并且可能无法访问您的 UI 实例。
标签: html google-apps-script serverside-javascript