Hey there!
Here is my HTML code:
<html>
<head>
<title>HTML</title>
crossorigin="anonymous" referrerpolicy="no-referrer" />
referrerpolicy="no-referrer"></script>
<script>
$(function () {
$("#datepicker").datepicker({
beforeShowDay: function (d) {
var day = d.getDay();
return [day != 0 && day != 2 && day != 3 && day != 4 && day != 5 && day != 6];
},
});
});
</script>
</head>
<body align="center">
<form id="Form" onsubmit="runThis()">
<input type="text" id="datepicker" value="YYYY-MM-DD"/>
<input type="submit" value="Submit">
</form>
<script>
function runThis() {
alert("Hi!");
google.script.run.withFailureHandler(e => alert(e)).doSomething();
}
</script>
</body>
</html>
Here is my apps script code:
function calendar() {
var html = HtmlService.createHtmlOutputFromFile("CalendarInput");
SpreadsheetApp.getUi().showModalDialog(html, "Choose the Monday start date from the calendar:");
}
function doSomething() {
SpreadsheetApp.getActive().toast("hello");
console.log("doing something");
return true;
}
In the project where it is not working, when I hit "submit" in the HTML modal, the alert "Hi" shows up so I know it is running the function runThis() in the HTML code. But it isn't running doSomething(). I checked my execution history and doSomething() isn't there. When I run doSomething() in the console, I successfully get the toast and log. When I wrap it in a failure handler, it fails every time with NetworkError: Connection failure due to HTTP 500.
But like I said, when I copy and pasted the code into another project, it works just fine. Does anyone know if I am missing something with configuration or might be causing this error?
Thank you so much!