Would anyone please be so kind as to provide me with a working example of a GoogleApps script to generate a three-page Google Form, whose first ListItem question would contain page-number choices that would point the respondent to Page 2 or 3, with some questions already present on Pages 2 and 3? It seems perfectly possible to point to a deliberate page only when the pages are empty, but it does not work when questions are added on the pages.Having run into this problem, I have found two contributions on Stack Overflow (see below, including the code I also tried), where the problem remains unsolved, with answers limited to empty pages only.
Many thanks for a working piece of code.
but it does not work when questions are added
...providing the code that didn't work for you is best, but modifying my previous example you linked...
function myFunction() {
var title = 'GoToPage item example';
var form = FormApp.create('My form example')
// Create pages and items in order
var item1 = form.addListItem().setTitle('First question');
var page2 = form.addPageBreakItem().setTitle('Second page');
var item2 = form.addListItem().setTitle('Second question')
var page3 = form.addPageBreakItem().setTitle('Third page');
var item3 = form.addTextItem().setTitle('Third question')
// Now set item choices
item1.setChoices([
item1.createChoice('Choice 1',page2),
item1.createChoice('Choice 2',page3)
]);
item2.setChoices([
item2.createChoice('Choice 3',page3),
item2.createChoice('Choice 4',FormApp.PageNavigationType.SUBMIT)
]);
}