Hi I am looking to add questions to google form from google sheet. I have already figured a way of adding choices.
The sheet looks like this with the column header being the questions and everything under the header to be single choice answers to each question (these are just two of 60-70 questions),
How do I start from a blank form like below?
I have got the below code to update the answers,
function updateForm(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var sheetName = sheet.getSheetName();
var getCol = e.range.getColumn();
if(sheetName == 'Names' && 1){
var nameValues = sheet.getRange('A2:A10').getValues(); // Get name values
var form = FormApp.openById('---------'); // ID of form
var formItems = form.getItems();
var question = formItems[2].asListItem(); // Get the second item on the from
var names = []
for(var x = 1; x < nameValues.length; x++){
if(nameValues[x][0] != ""){ // Ignores blank cells
names.push(question.createChoice(nameValues[x][0])) // Create an array of choice objects
}
}
var setQuestion1 = question.setChoices(names); // Update the question
}
}
Any guidance on helping input the questions automatically on the google form is appreciated!