Google Forms API - navigation pages (Go to Section) don't work as configured

46 views Asked by At

I'm using the Google Forms API to create a form where one of the alternatives is "submit this form" while the others will collect the necessary information, as in the example below: enter image description here

enter image description here The created form seems ok. However, when opening the form, instead of having the last option pointing to Section 2, it shows "Submit Form".

Form link: https://forms.gle/J5aQwFLHFuv635Vd8

Bellow you will find the code:

function SampleFormCreation() {

  var sampleForm =  FormApp.create('Sample form lu.c.n'); 
  sampleFormUrl = sampleForm.getEditUrl();

  var item = sampleForm.addMultipleChoiceItem();
  item.setTitle('Choose one')
      .setChoiceValues(['p1', 'p2', 'p3'])
      .setRequired(true);
  item = sampleForm.addDateItem();
 

  // Add Page break and dropdown menu
  mainPage = sampleForm.addPageBreakItem().setTitle('Main Page');
  sampleSelectionItem = sampleForm.addListItem().setTitle('sample selection')
                                                .setRequired(true);
  
  var pages = [];
  var itemChoices = [];  
 
  // Add one page for each blood measure that can be a number greater than zero or a multiple choice
  for (var i = 0; i < 3; i++) {
    pages[i] = sampleForm.addPageBreakItem().setTitle( 'Option' + (i+1));
    item = sampleForm.addTextItem();
    item.setTitle('option' + (i+1)).setRequired(false);
    pages[i].setGoToPage(mainPage); 
  }

  // Add the dropdown choices for blood Test selection.  First option should be "Submit Form"
  itemChoices.push(sampleSelectionItem.createChoice('Submit Form', FormApp.PageNavigationType.SUBMIT));
  for (i = 0; i < 3; i++) {
    itemChoices.push(sampleSelectionItem.createChoice('option' + (i+1), pages[i]));
  }
  
  sampleSelectionItem.setChoices(itemChoices);
} 

It seems the issue is in the Google Form UI. Any ideas on how to fix that?

Thanks

0

There are 0 answers