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.

1 Answer 1

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)"/>
Sign up to request clarification or add additional context in comments.

1 Comment

That worked, thanks :) It's odd that it has been working for a year and suddenly stopped, but it's fixed now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.