The same function works fine, if the code is not imported and just in the sheet.
The .withSuccessHandler() don't pass on the return value to the called function.
The code in code.gs returns a Boolean (the log gets it), the function called with .withSuccessHandler() doesn't get it and the variable is undefined.
html
<html>
<form id="myForm">
[...]
<input type="button" value="Submit"
onClick="google.script.run.withSuccessHandler(DataSaved).withFailureHandler(Error).processForm(this.form)"
/>
</form>
<div id="Message"></div>
<script>
function DataSaved(ret){
if(ret==true){
document.getElementById('Message').innerHTML = "Finished!";
}else{
document.getElementById('Message').innerHTML = ret+"Wrong Sheet!";
}
};
function Error(err){
document.getElementById('Message').innerHTML = "An error occurred: "+err;
};
</script>
code.gs
function processForm(myForm) {
var data = myForm.data
var fu = ParseExport(data)
console.log(typeof fu);console.log(JSON.stringify(fu))
return fu
}
The resulting line is: undefinedWrong Sheet!
Stackdriver
Stackdriver-Protokolle
29.06.2019, 19:39:11
FEHLERBEHEBUNG
boolean
29.06.2019, 19:39:11
FEHLERBEHEBUNG
true
I don't know where to look for the mistake anymore. Even moved the google.script.run function in the script block to test if it changes anything (it don't). The error handler works fine...
console.log(typeof fu);console.log(JSON.stringify(fu)). ProvideParseExportreturn type/value - TheMasterretdefined somewhere else? Can you try moving the script block above the form block? - TheMasterfunction processForm(myForm) {return true}- TheMasterretanderrare the only variables in the html. Renamed it anyway to be sure, but didn't change anything. - Tezexlo