I have a couple of scripts that don't work anymore although I didn't make any change. I don't spend a lot of time programming these last month so I didn't notice it right away... Here is a simplified code that used to work and that doesn't, I can't figure out my error. The HTML part is entirely built on server side since it's a very simple code (runs from a spreadsheet).
function myFunction() {
var doc = '<body style="font-family:arial,sans;font-size:12pt">';
doc+='<select id="target" multiple style="font-family:arial,sans;font-size:12pt">';
doc+='<option value="1">choice 1</option><option value="2">choice 2</option><option value="3">choice 3</option></select><br><br>';
doc+='<input type="button" onClick="processJS()" style="background:#BFA;font-size:12pt" value="Validate"/>';
doc+='<script>function processJS(){var e=document.getElementById("target");var values=Array.from(e.selectedOptions).map(option => option.value);';
doc+='console.log(JSON.stringify(values));google.script.run.withSuccessHandler(function(msg){ window.alert(msg);google.script.host.close;}).processGSTest(values)};</script>';
doc+='</body>';
var ui = HtmlService.createHtmlOutput(doc).setWidth(500).setHeight(250);
SpreadsheetApp.getUi().showModelessDialog(ui, "test");
}
function processGSTest(values){
Logger.log(JSON.stringify(values));
return "processGSTest ok";
}
I get an error in JS console like this when I hit "validate" :
the HTML rendered window looks like this :
EDIT
Following comments (thanks again) I've got a few more informations :
- when using another browser the scripts works fine
- when using chrome and adding an
withFailureHandlerit still fails with the same console message without handling the failure (Chrome Version 81.0.4044.122 (Build officiel) (64 bits) on Mac OS High Sierra) - when calling the same function from a custom menu the script works fine even in the same Chrome session
conclusion of this edit : I don't understand the issue :)


google.script.host.closebe called?google.script.host.close(). Also try clearing browser cache,log out and loginfailureHandlermight help to catch theuncaught