I have some data in a Google Sheets file.
I want to get a Google Forms dropdown list to be updated automatically from that list.

Is it possible?


Thanks for the spell check. Unfortunately this is a direct copy paste of the codes from developers.google.com
I guess they need to correct their site.

Yes its possible

This can be done via google app script .setChoiceValues(values)

See full script here

sample code:

var item = form.addListItem();
item.setTitle('Do you prefer cats or dogs?')

Instead of typing in the actual choices into this bracketed part of the script like the code sample above (cats) - use a cell & column range instead (4,3) that points to data range on the sheet where your dynamic dropdown choices are located, like this here.
This piece of code is referencing an active sheet but you can modify the code to get cell ranges by referencing the sheet id instead

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var range = sheet.getRange("B2:D4");

// The row and column here are relative to the range
// getCell(1,1) in this code returns the cell at B2, B2
var cell = range.getCell(1, 1);

You can set a choice for the dropdown list items by referencing the Google sheet cell range that the form is linked to or any other sheet by referencing the Google sheet id & sheet name where your dropdown choices are located. You can get the sheet id by looking at the web link of your Google sheet in your browser. Its the long string of characters & numbers. (or see how to get the sheet id by code.

Once done, to get the form to auto update, use sheet or form triggers to call the update list script so that the form can be updated with the new choices once it reloads.

I did something similar recently- auto populating & auto updating a Google form with data values from the Google sheet after a response was submitted. Here is the working live sample form: https://support.google.com/docs/thread/48344518?hl=en

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.