1
votes

I'm not sure why but this google script won't run...am I missing something? Should just be a straight forward drop-down list in google form that pulls from a list in a google sheet. Thanks!

    function updateForm(){
  // call your form and connect to the drop-down item
  var form = FormApp.openById("1jkvyqmRwK_U9Ddn96LRRAxC0xjnuufo3JuIj9kszNQ8");

  var namesList = form.getItemById("1425039677").asListItem();




// identify the sheet where the data resides needed to populate the drop-down
  var ss = SpreadsheetApp.getActive();
  var names = ss.getSheetByName("Student Names");

  // grab the values in the first column of the sheet - use 2 to skip header row 
  var namesValues = names.getRange(2, 1, names.getMaxRows() - 1).getValues();

  var studentNames = [];

  // convert the array ignoring empty cells
  for(var i = 0; i < namesValues.length; i++)    
    if(namesValues[i][0] != "")
      studentNames[i] = namesValues[i][0];

  // populate the drop-down with the array data
  namesList.setChoiceValues(studentNames);

All it says when I run it is preparing to execute and then nothing.

1
I think that your script is correct. So for example, as a sample, how about creating new form and testing it? If this was not useful for your situation, I apologize.Tanaike
I've been successful by simply closing the editor and the spreadsheet and reopening it. Also you might check your executions to see if you have a bunch running. I find that happens a lot when I'm debugging with the new developers hub.Cooper

1 Answers

0
votes

Looks like this actually works. I closed out of the form and sheet per @Cooper suggestion and rebooted and that seemed to fix it. Thanks!