Dynamic dependent dropdowns on Google Form - google-apps-script

I need to add the following functionality on a google form -
I need to have two dropdowns on the form-
Dropdown1 values are being populated from the google sheet using a script.
Dropdown2 values must also be populated from the google sheet BUT must change based on the value selected in Dropdown1 on the form.
Since Dropdown1 has many values in the list, using the "go to section based on answer" is not an option to show Dropdown2.
How can I implement this cascading/dependent dropdown functionality dynamically on the google form (I guess using the google script and google sheet)?
Thanks in advance!

Answer:
Unfortunately, this is not possible using Google Forms.
Explanation:
In order to change the contents of later dropdowns based on the selected answer in a previous question, direct access to the browser session must be retrieved by Google's server before form submission. This isn't done.
Until a form has been submitted by the user, giving explicit permission to send the answers they have provided, the answers are not communicated to Google's servers and as such later questions can not change based on previous answers. Implementing this would be a privacy issue so I can not forsee Google creating this option in the future either.

Related

Moving an item from one Google form to a new Google form using google apps script

When editing a Google form manually, you can usually click on an item, and on the side appears a menu, which includes the button "import questions". This button is very useful for me as it allows me to collect questions from past Google forms and import them to new Google forms.
But I'm looking through the Forms documentation, and I can't figure out how to do this via Google apps script programatically.
Here is the documentation:
https://developers.google.com/apps-script/reference/forms/form
The closest thing to what I want is the .moveItem() method, which moves an item from one spot in a form to another. But it only works within the same form. I want to know if I could do it across forms. And ideally, instead of moving the item, it would make a copy of the item in the new form.
I considered the .getItems() method, but there doesn't seem to be a general .addItem() method I could use on the new form. Would I have to go through the painstaking process of having to identify each item type, and specify how the details of each one should be copied to the new form, including things like point values of a question and whether or not the question is required?
I want to import from forms that have all kinds of content: video, images, multiple choice questions, grid questions, number scale questions, etc. I feel that if I have to specify the details of each item type, it would take too long, and I would be bound to miss something or run into an error that may be impossible to solve. Is there not an easier way?
And if specifying each item type is what I have to do to import everything properly, has someone else created that code already that I can re-use?
Issue:
In the current stage, unfortunately, it seems that Forms Service cannot copy all items. Ref1, Ref2 Ref3. And, unfortunately, moveItem can be used for the same Google Form as you say.
Workaround:
In your situation, as a workaround, how about copying the source Google Form? And, when there are some items you want to remove, you can remove them. I thought that this process can be achieved by Google Apps Script.
But, I'm not sure about your actual Google Form. So I'm not sure whether this is a suitable method.
Future:
Recently, Google Forms API was announced. Ref When this API got to be able to be used, your goal might be able to be achieved by retrieving the object from Google Form. Unfortunately, I'm still not sure about the detail of it.

FILE_UPLOAD item type in Google Apps Script (GAS) for Form Submission

I've seen FILE_UPLOAD item type in google forms regarding this topic.
My problem is related, but somewhat different--perhaps someone can recommend a workaround?
Situation: Using Google Forms as content submission and editing tool for certain kinds of "documents," with a specific form for each document.
Objective: copy an original form submission to create through GAS a NEW form submission with the same item responses.
This is based on a response in the original form submission indicating that a variant also needs to be created based on the original content.
Example: Another form entry is needed where the original content is translated to a different language (with first draft using google translate and then revised by native speaker using the Google form). In other cases, only portions of a long original submission need to be revised to create the variant document, where the revisions are made to the duplicated submission in the Google form.
Things are fine except where the form(s) have image upload options and I need to copy the FILE_UPLOAD content of the original form response back into the new scripted form submission. But it appears required to specify the item type (e.g., .asTextItem(), .asCheckBoxItem(), etc.). But there is no .asFileUploadItem() option (I tried using it), and therefore an error is thrown, preventing the copy of FILE_UPLOAD content into the corresponding question item of the form. I've tried using .asTextItem(), since the G-Drive address is just a text string (at least in the paired Google Sheet), but the Form won't accept that. It seems (at least in our case) that the original file location would work for all variant duplicates that retain the same image, so copying the content (the G-Drive location of the image) should be fine, if GAS allowed me to do that.
Is there any workaround provided by Google, now that it is a year later than the previous post I found (above)? Has anyone come up with a workable solution that might work for my case?
Thanks so much for any help!

Autocomplete Google Form based on values in spreadsheet

I'm writing a script to autocomplete some fields in a Google Form based on a field that has started to be filled out. For argument's sake, let's say it's address. So when a user fills the form out like so:
And if in a spreadsheet called defaults there is a row with this address:
Not only that field is updated, but any other fields that match are, too (like name and email).
Does anyone have any suggestions for me? My research has turned up nothing too useful for this case.
It's not possible to create an autocomplete field in a live Google Form. You can create a stand alone Apps Script Web App using HTML, CSS, and JavaScript. You could even style it to make it look like a Google Form.

Google Script: Using an input text box in a form that pulls items from the sheet and presents as options

I am currently developing a program in Google Script that works with Google Sheets. I've created a tab that serves as the UI and have multiple tabs for each data type to store the data.
When I first started, I originally reserved some cells on the UI tab that I used as the inputs for creating a parent-child relationship instance. To do this, I directly set validation on each of the cells and used the "List from a range" Criteria to provide the drop-down list to provide the options to select from.
Now, I am trying to move this input off of the cells in the UI tab and into the sidebar. I am now using HTML Service and am creating a form to handle this functionality. However, I can't figure out where to get started to provide the same drop-down functionality for each of the text inputs in the form as I had when I used the cell validation.
Does anyone know what syntax is used to do this?
Thank you,
Nicholas Kincaid
jQuery auto-complete combo-box is what will take care of this => jqueryui.com/resources/demos/autocomplete/combobox.html

Grab current selection from a google form section

I have a google calendar that lists multiple free classes that are available each month. Currently the way people sign up is that they click on a link to a google doc and enter their names, but a blank work doc with names isn't very professional. Instead I'm created a google form that will send the responses to an excel spreadsheet, but need some help.
Currently the form first question asks "what date is the class you'd like to addend?" - Is there any way I can get the users response to that first question without having them submit the form?
Essentially I'd like for them to enter the date and use the getEventsForDay(date) function to create the second question dynamically populated with the calsses for the date they selected. Then have them choose the class with radio buttons. Is there any way to do this or would I have to have them select a date and then from that submit spawn a new on the fly form that then would list the classes for the date they selected?
For what I know you can't do that in a single form. You will need to do it with 2 forms. You can prefill the other form with some informations of the first form to make the bond.
But the best solution is: not to use the Google Forms and build your own form in apps script. Here an example and the code here.