Currently
I have a sidebar in Google Sheets (launched on open using a project trigger) with a button that is meant to call a script from a .gs
file
The code:
.gs
function addSideBar() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setTitle('My Sidebar')
.setWidth(500);
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showSidebar(html);
}
function logMe() {
console.log("I am a log!");
}
.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<button value="Connect" name="Connect" onclick="connect()">Connect</button>
<br>
<script>
function connect() {
google.script.run
.withSuccessHandler(function() {console.log("More Success!")})
.withFailureHandler(function(err) {
console.log("Error Message:")
console.log(err.message)
})
.logMe();
console.log("Success!");
}
</script>
</body>
</html>
Issue
I can't even get the HTML code to call a simple log function server side! I am expecting a log (somewhere) to read I am a log!
but this doesn't show up on the logs either client or server side.
The logs show that the failure handler is being called with the message: "We're sorry, a server error occurred while reading from storage. Error code PERMISSION_DENIED."
It's weird because I have been able to get an HTML Service side script to call the server before in a separate project with a pop-up window, and am wondering if it's due to:
- the use of the side bar, or
- the way I setup my trigger to create the side bar.
Any help would be appreciated.