I'm using google.script.run
in html template file, and it works well as I expected.
but it doesn't work after adding the oauthScope "https://www.googleapis.com/auth/tasks" to appsscript.json file.
Error log is just uncaught
, so couldn't investigate the cause more.
Is there any relation or dependency between both?
I need to add this to manage google tasks.
Let me share the detail information.
there are 2 scripts
・container bound script for GSS
・library script referred by above container bound script.html template in library script
・call google.script.run.registerSome() in html template.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<button onclick="showMessage()">showMessage</button>
<script>
function showMessage () {
google.script.run.showMessage();
}
</script>
</body>
</html>
- source code in library script
・show above html file as dialog on GSS Edit.
function onEdit(e, spreadsheetId) {
const htmlTmpl = HtmlService.createTemplateFromFile('someHtml')
const html = htmlTmpl.evaluate().setWidth(900).setHeight(600)
SpreadsheetApp.getUi().showModalDialog(html, 'title')
}
function showMessage () {
Browser.msgBox('Hello world')
}
- appsscript.json in library
・before adding the "https://www.googleapis.com/auth/tasks"
{
"timeZone": "Asia/Tokyo",
"dependencies": {
},
"webapp": {
"access": "ANYONE",
"executeAs": "USER_ACCESSING"
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": [
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/spreadsheets.currentonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/script.container.ui"
],
"runtimeVersion": "V8"
- container bound script
・if this function is not declared,showMessage is not a function
log is output on the browser console.
・_onEdit is bind to installable trigger onEdit.
(to use some process asking the user for authorization)
function _onEdit(e) {
// `-` is symbol for library.
_.onEdit()
}
function showMessage () {
//no logic here
}
- replicating
- Add library script to container bound script(symbol is
-
in above sample) - Bind
_onEdit
function to installable edit trigger. - Open GSS
- Edit some cell
- Dialog is shown
- Press the
showMessage
button Hello world
message is shown- Adding the oauthScope "https://www.googleapis.com/auth/tasks" to appsscript.json file in the library.
- Then, do 3-6 process again
- Message is not shown and error log
uncaught
is output.
Does anybody know what the cause is?
Thanks,