1
votes

I have a script that used to work just fine, but has suddenly stopped working.

The user selects an option from a user-created menu, which launches a dialog box (HTML Service form) to collect two parameters. This is all working fine.

When the users submits the form, this code should execute.

<input type="submit" value="Submit" class="submit" onclick =
"google.script.run.withSuccessHandler(google.script.host.close())
.createAgenda(this.parentNode)"/>

The form is closing (google.script.host.close() works), but the createAgenda function is not being called.

1

1 Answers

1
votes

The parameter for withSuccessHandler() (and withFailureHandler()) is supposed to be a callback function. You've provided something that isn't a function: google.script.host.close(). Since you've included the parentheses, close() gets executed first, to obtain a return value for withSuccessHandler(). That closes the dialog, and halts the client-side JavaScript.

You just need to remove the parentheses, referring to the function by name only:

<input type="submit" value="Submit" class="submit" 
 onclick="google.script.run
                       .withSuccessHandler(google.script.host.close)
                       .createAgenda(this.parentNode)"/>