I want to collect and validate a value (PIN) in a Google Form. The Form has 2 pages, and I'd like the validation to affect form navigation:
If PIN matched with a value in Column N of the response sheet, continue to page 2 of the form
If PIN not matched, Do not continue.
Can this be done with Google Apps Script?
You are not able to create this type of dynamic form using the Google Forms Service, because there is no interaction between the service and scripts during form entry, except upon Form Submission. In the case of a multi-page form, a script has no way to know that a user has completed one page and gone on to another.
You could achieve this using the HtmlService or UiService, by writing your own form.
Not sure you can do this with Google Forms and Apps Script.
But I have done exactly this with UiApp/Html Service in Apps Script. I used it for a light-duty user authentication.
Related
I'm attempting to create a Google Script that allows branching logic, however I don't see in the Google App Script documentation a method that verifies if a checkbox is marked as true or false.
Is there a way to confirm in a script, if an option is selected or not before submitting the whole Google Form?
To prevent submitting the form depending on the checkbox value, you can make the selection required, or you can validate the response.
To implement the branching logic in the forms, you must use the multiple choice control.
With Apps script you have much more validation options, but only after the form has been submitted.
In my Google Form I want to show the user a dropdown list consisting of several values from which he can choose one value. Such as:
Guernsey
Hereford
Jersey
But when his response gets stored into the response sheet I want it to be stored as a corresponding coded value, such as:
301
371
422
Is there any way to do this when I build a Form? Can it be accomplished with Google App Script?
Google Forms doesn't include form responses codification and the built-in feature that send form responses to an spreadsheet either. One alternative is that you use on form summit installable trigger. There are one for scripts bounded to forms and another for scripts bounded to spreasheet, each one having their own event object. For details see https://developers.google.com/apps-script/guides/triggers/events.
My requirement is to validate the some of the form fields against some data upon form submission. If the data doesnt match up, I wanted to reject the form submission and display an error. Is this possible?
Thanks!
This is a built in feature for Google Forms:
https://support.google.com/docs/answer/3378864?hl=en
I have a Google Form and a script and a script bound to the form.
I'm trying to get a function to run when a user fill in the form.
But the only function I get to run is when a hook it to the OnFormSubmit trigger.
No other function is running, no matter what I try.
Can I run a function i Google App Script on initial load when a user is filling the form? Is this possible?
Thanks
More details (I'll accept some other way to accomplish the task):
the function should capture some url parameters I pass to the form, and send it over to Google Analytics... I believe that part is solved here: Google Forms & The Measurement Protocol
As the form has several pages, the parameters I pass to the first page gets lost when the user goes to next pages, so I cannot capture them when submitting the form - therefore I'm trying to do it whenever the users first edits the form.
I tried to add the params as prefilled fields on a hidden page, but if it is hidden then it too gets lost on submitting...
Since Sandy did not write out an answer, I will.
You cannot execute Apps Script as part of a form when the user visits it. You can't modify a form as the user is filling it out (Dynamic form...etc). If you need this type of behavior, you will need to create your own form as part of a Apps Script Web App.
Web App information: https://developers.google.com/apps-script/guides/web
I am using a form to collect booking details and have the script attached to the form (so that the form submit trigger will trigger when the response is edited, which the spreadsheet bound version does not allow) which sends an email, schedules calendar events, creates confirmation documents etc on form submit. Using if statements I have provided the user the ability to avoid 'click the box to not send the customer an email on submit' functionality so that the form responses can be edited without triggers the automated functions, but that relies on the user remembering to click those boxes.
A better solution would be to be able to have the script, as its final function, change the item response, so that when the form is edited in future, the automatic functions are already disabled.
I do not want to create a new form response (although it would be possible to tweak the pre-populated url to create a duplicate with the appropriate changes)
FormResponse.withItemResponse(response) specifies that it doesn't work on stored responses
It is so easy to view form responses, and with the native edit response url functionality I figured editing a single item response would be doable, but so far it has eluded me.
Is there a way to do this?
Thanks
At this time Form responses could only be created programmatically, they can't be edited programmatically. Consider to submit a feature request through Google Apps Script Issues