Nakul Upadhya
Nakul Upadhya

Reputation: 488

Run Apps Script Client Side on Google Form Submit

I'm currently trying to make a paperwork wizard using google forms and apps script. At the end of the form, I'm trying to run an Apps Script once the form submits and display a HTML window. I tried using FormApp.getUI()along with the apps event trigger, but I keep getting the error Exception: Cannot call FormApp.getUi() from this context. From other posts it seems like this error is because the trigger runs the script server side. Is there a way to run this script client-side so the HTML window can be displayed?

EDIT: Conditional Sections Google forms this question is different from the one I'm asking now.

EDIT2: Code

Code.gs

function myFunction() {
  var lock = LockService.getScriptLock();

  var html = HtmlService.createHtmlOutputFromFile('display');
    FormApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
    .showModalDialog(html, " Let's check if you need to present!");
    SpreadsheetApp.flush();
    lock.releaseLock();
}

display.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <p>Test</p>
  </body>
</html>

Upvotes: 1

Views: 340

Answers (1)

Wicket
Wicket

Reputation: 38435

From the question:

At the end of the form, I'm trying to run an Apps Script once the form submits and display a HTML window.

This is not possible.

If you collected the respondent email address you could send them an email

Upvotes: 3

Related Questions