1

I have set up an item on my Google Form to set list based on values from a Google spreadsheet, code is:

function updateForm(){

  var form = FormApp.openById("FormID");
  var namesList = form.getItemById("ItemID").asListItem();
  var ss = SpreadsheetApp.getActive();
  var names = ss.getSheetByName("SourceSheetName");

  var namesValues = names.getRange(2, 1, names.getMaxRows() - 1).getValues();

  var List = [];

  for(var i = 0; i < namesValues.length; i++)    
    if(namesValues[i][0] != "")
      List[i] = namesValues[i][0];

  namesList.setChoiceValues(List);

}

This works perfectly fine.

What I really want is to set each of the items listed on a spreadsheet to take you to a specific section on the Google Form.

I know this can be done manually on the Google Form by using 'Go To Section Based On Answer', but I was wondering if I can add a second column on the source spreadsheet to list the sections and amend my code accordingly?

EDIT - this is not a duplicate to another question which is mentioned below. The question asked previously had 2x choices set in the code. My question involves a set of responses set in a Googlesheet that auto populates the Google Form. What I really want is to auto set Go To Section Based on Answer automatically too. I hope this makes sense. Thanks

Oday Salim
  • 1,129
  • 3
  • 23
  • 46
  • 1
    Possible duplicate of [\[google form\]Creating form with a script : Page Break and go to page issue](https://stackoverflow.com/questions/17083500/google-formcreating-form-with-a-script-page-break-and-go-to-page-issue) – Rubén May 01 '18 at 14:17
  • That sounds exactly like a duplicate. You ask how can you programmatically set the "go to page based on answer," and that question shows how to do that. Have you studied that answer? Have you tried to implement what it suggests? – tehhowch May 02 '18 at 12:49

0 Answers0