Populate Google Forms Dropdowns Dynamically from Spreadsheet
Reads dynamic inventory, available event time slots, or staff names from Google Sheets and automatically updates dropdown choices in an active Google Form.
https://www.googleapis.com/auth/forms • https://www.googleapis.com/auth/spreadsheetsfunction syncFormDropdownWithSheet() {
const formId = 'PASTE_FORM_ID_HERE';
const form = FormApp.openById(formId);
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Options');
// Read choices from Column A
const data = sheet.getRange(2, 1, sheet.getLastRow() - 1, 1).getValues();
const choices = data.map(r => r[0]).filter(String);
// Find target dropdown question by title
const items = form.getItems(FormApp.ItemType.LIST);
items.forEach(item => {
if (item.getTitle() === 'Select Product / Service') {
const listItem = item.asListItem();
listItem.setChoiceValues(choices);
}
});
}Line-by-Line Code Explanation
Step-by-Step Setup & Deployment
- Create a dropdown question in Google Forms titled "Select Product / Service".
- Put available choices in Column A of an "Options" sheet tab.
- Set an hourly trigger to keep dropdown choices synchronized.
Best Practices for Quota & Rate Limit Management
When deploying this automation in Google Workspace, adhere to these operational principles:
- Batch Reads & Writes: Never execute
getValue()orsetValue()inside loops. Read ranges into memory in 1 call, process arrays in V8 memory, and commit changes with a singlesetValues()call. - Execution Timeouts: Apps Script terminates scripts exceeding 6 minutes. For multi-thousand row datasets, implement batch pagination with resume timestamps stored in
PropertiesService. - OAuth Permissions: Scope your manifest (
appsscript.json) narrowly to prevent security prompts from alarming external team members.
Frequently Asked Questions
Is Google Apps Script completely free to use?
Yes. Google Apps Script is built into all free Google accounts and Google Workspace editions. There are no server fees or subscription costs for running scripts within daily quotas.
Can I run this script on an automated schedule without keeping my computer on?
Yes. Time-driven triggers execute on Google's cloud infrastructure. Your script will run reliably even when your computer is closed or offline.
More Google Forms Automation Snippets
Google Forms: Automated Dynamic Email Confirmation on Submit
Listens for Google Form submissions, extracts respondent name, email, and requested service, and dispatches a personalized HTML confirmation receipt immediately.
Google FormsAutomatically Close Google Form When Max Submissions Reached
Tracks event registrations or survey entries and automatically closes the Google Form and displays a custom "Event Sold Out" message when capacity is reached.