π How to Add Options in Google Forms Questions from Google Sheets
1. Overview
\[ \begin{array}{l} \textbf{Google Forms can be dynamically populated with options --} \\ \text{directly from a Google Sheet using Google Apps Script} \\ \textbf{This allows you to keep your form synchronized --} \\ \text{with a spreadsheet list.} \end{array} \]
2. Core Steps
\[ \begin{array}{ll} \mathbf{Step\ 1:} & \text{Create a Google Form and note its form ID.} \\ \mathbf{Step\ 2:} & \text{Create or use a Google Sheet containing your list of options.} \\ \textbf{Step 3:} & \text{Open the Script Editor in Google Sheets (Extensions $\rightarrow$ Apps Script).} \\ \mathbf{Step\ 4:} & \text{Write a script to fetch values from the sheet and update the form question.} \\ \mathbf{Step\ 5:} & \text{Run the script and authorize permissions.} \end{array} \]
3. Sample Google Apps Script
// Replace with your Google Form ID
var formID = 'YOUR_FORM_ID_HERE';
// Question title in your form
var questionTitle = 'Choose an Option';
function updateFormOptions() {
var form = FormApp.openById(formID);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Get list from column A
var data = sheet.getRange(1, 1, sheet.getLastRow(), 1).getValues();
var options = data.map(function(row) { return row[0]; });
// Find the question and update choices
var items = form.getItems(FormApp.ItemType.MULTIPLE_CHOICE);
for (var i = 0; i < items.length; i++) {
if (items[i].getTitle() === questionTitle) {
items[i].asMultipleChoiceItem().setChoiceValues(options);
break;
}
}
}
4. Important Notes
\[ \begin{array}{l} \text{β’ Ensure that the sheetβs first column contains your list of options.} \\ \text{β’ Match the question title exactly when searching for the question in the form.} \\ \text{β’ Apps Script requires permission to edit the form.} \end{array} \]
5. Conceptual Flow (in LaTeX)
The process can be described as:
\[ \text{Google Sheet Data} \xrightarrow{\text{Apps Script}} \text{Google Form Question} \]
Where: \[ \text{Options} = \{ \text{Cell}_{A1}, \text{Cell}_{A2}, \ldots, \text{Cell}_{A_n} \} \]