The script completed but the returned value is not

2019-06-01 03:08发布

问题:

I am working on a way to create a form from the ground up, I have no intentions of using google forms as it limits my options. But I am running into a problem when running my script. I get this error message when reaching the url extracted when I publish as a web app:

"The script completed but the returned value is not a supported return type."

Here is the script I am using:

function doGet() {
return HtmlService.createTemplateFromFile('Index')
}

function doSomething(form) {
var spreadsheetKey = "1C26wx6zBCGvkQEVF2xMVRoR8L0NCXQAvjdJSlnE3Y7g";

var sheet = SpreadsheetApp.openById(spreadsheetKey).getActiveSheet();
var textBoxValue = form.textBoxName;
var lastRow = sheet.getLastRow();

var targetRange = sheet.getRange(lastRow+1,1,1,1).setValues([[textBoxValue]]);
}

and the correspnding index file, simply titled "Index":

<script>
function formSubmit() {
google.script.run.doSomething(document.forms[0]):
}
</script>

<form>
<input type="button" value"Not Clicked"
onclick="formSubmit()" />
<input type ="text" name="textBoxName" />
</form>

any suggestions on what might be wrong, I got this from somewhere else where it seemed to be working, but that was 2 years ago. Maybe something has changed in the mean time?

回答1:

.evaluate() is needed after .createTemplate(), .createTemplateFromFile()