0

I have created a script that receives the POST of an HTML form, then updates a Google Sheets with the content of the POST. The script has been published "Deploy as web app ...". The form is defined as follows:

<form action="https://script.google.com/macros/s/AKfycbwjlImSal ... gUBK6hQnLTIWAwE/exec" method="post" id="frm">

and submitted as follows:

    document.getElementById("frm").submit();

I also have created a form within an HTML document that submits (via POST) to the above script web app. I use the following code to display the HTML document within Google Docs:

html = HtmlService.createTemplateFromFile('Apartment')
      .evaluate()
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  html.setHeight(750);
  html.setWidth(900);
  DocumentApp.getUi().showModalDialog(html, 'Apartment Inspection');

When I open the HTML document directly into my browser (Firefox), the POST executes as designed. The target sheet is updated. When I go through Google Docs using the above code, no submission occurs.

Is there a way to make this work?

  • What do you mean by "have created a form within an HTML document"? How do you open int directly into your browser? Are you able to create a Minimal complete and verifiable example? – Rubén Dec 15 '17 at 0:30
  • The document Apartment.html is displayed via the showModalDialog above from within Google Docs script. The same document can be opened via the File:// system directly into the browser. This works; opening in Google Docs does not work, even though the javascript code is identical. – rka Dec 15 '17 at 14:06
  • An HTML file hosted on a Google Apps Script project can't be opened using File://. I think that you mean that you are opening a file having the same content but the Google Apps Script HTML Service has some "special rules". See Custom dialogs. Consider to create a Minimal, Complete and Verifiable Example including the HTML code. – Rubén Dec 15 '17 at 15:11

Your Answer

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

Browse other questions tagged or ask your own question.