In Google Form through app script, how to display question 2 with prefilled answer only when the user responded to question 1 correctly?

151 views
Skip to first unread message

Bharath Kumar

unread,
Apr 30, 2020, 4:18:49 AM4/30/20
to Google Apps Script Community

I would like to build a form which should have a question 1 to enter a code (which we have already shared to recipients for identification purpose) upon submitting the response code, a validation should perform and if it's successful, a question 2 with pre-filled answer should be displayed.


After the response code entered by user on the form for Question 1, 

How do I get the response code provided by the user? 

How to validate it dynamically with the list of overall codes which I maintain in an excel? 

How to display the pre-filled question 2 with answer on the same form?


I have tried using App script through 'onOpen' Form triggers, but didn't work out well.

'onOpen' Form Event trigger worked only when a form opened in an edit mode by form creator, but ideally we expected that it will trigger when the recipient who receives this link to fill the form opens it.


Any suggestions from App scripts experts also would be highly appreciated.

Mani Doraisamy

unread,
Apr 30, 2020, 6:30:24 AM4/30/20
to google-apps-sc...@googlegroups.com
Hi Bharath,
  1. onOpen will fire when the form editor is opened, not when users are filling the form.
  2. onFormSubmit  will fire when a response is submitted to the form. Again not while users are filling the form.
If you want to change the behavior of the form when users are filling it, you can use Formfacade addon (Disclaimer: I wrote it). It allows you to trigger javascript based on previously answered form fields -  https://formfacade.com/faq/google-forms-calculated-fields.html

regards,
mani



--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/bfe94761-02f4-4140-8c1b-041aa21d5201%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages