1

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.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
kxm
  • 55
  • 7

1 Answers1

1

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)"/>
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • That worked, thanks :) It's odd that it has been working for a year and suddenly stopped, but it's fixed now. – kxm Jun 19 '16 at 09:24