0

Here is my HTML file "Creds.html":

<form id="Creds">

  Client ID: <input id="id" type="text" width="45"><br>

  Client Secret: <input id="secret" type="password" width="45"><br>

  <input id="submit" type="button" value="Submit" width="15" onclick="google.script.host.close()"><br> 

</form>

Here is the Google Sheets bound Apps Script that is attempting to display it:

function setCreds () {

  var ui = SpreadsheetApp.getUi();
  var form_cred = HtmlService.createHtmlOutputFromFile('Creds');

  //var newcreds = ui.showSidebar(form_cred);
  var newcreds = ui.showModalDialog(form_cred);
...
}

The .ShowSidebar line works when I switch the // comment line. However, the .showModalDialog line gives the following error:

Exception: The parameters (HtmlService.HtmlOutput) don't match the method signature for Ui.showModalDialog.

Why am I getting this error? What needs to change?

1
  • NOTE: The HTML headers in the HTML file were removed from my HTML code above when I submitted this question, even though I pasted them in. They are there in my file.
    – Trashman
    Feb 15 at 1:24

1 Answer 1

1

showModalDialog requires a title. Doc ref

Change: var newcreds = ui.showModalDialog(form_cred)

To: var newcreds = ui.showModalDialog(form_cred,"title")

2
  • I should have checked the documentation closer. In my defense, the error generated is not helpful to solving the problem. If nothing else, hopefully this question/answer is an easy to find solution for anyone else having the same problem.
    – Trashman
    Mar 3 at 15:49
  • To be fair, error messages are rarely helpful. But Google is your friend. It's good to remember when anything error occurs that it's almost certain that it has happened to someone else before.
    – Tedinoz
    Mar 3 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.