[更新以缩小焦点]我无法获得使用GAS构建的多节表单。
使用form.addPageBreakItem描述了部分,但是如果你随后放入一个改变部分流程的小部件(例如.addMultipleChoiceItem),它将无法构建,因为你导航到的部分还没有已定义。
使用.setGoToPage()函数有同样的问题。
这些功能如何用于控制流量?
答案 0 :(得分:3)
终于明白了。这是一个演示,这是一个收集网球比赛结果的表格。 (允许的比赛可以是短组,即5场比赛)
/*
* makeMultiForm - Build a multi-sections to collect Singles or Doubles results
*/
function makeMultiForm() {
var form = FormApp.create('Match Results Entry')
.setConfirmationMessage('Thank you! Your results have been recorded');
form.setTitle("Demo Tennis Results Form");
// Start by laying out the bare-bones structure. This defines the different
// sections, and the bare widgets in each section.
// Note that you can't add any flow-routing details at this point, because
// the destinations most likely haven't been defined yet
var itemCompetition = form.addMultipleChoiceItem().setTitle("Which Competition");
var itemMatchDate = form.addDateItem().setTitle("Match Date");
var sectSingles = form.addPageBreakItem().setTitle("Singles Competition");
var itemPlay1 = form.addListItem().setTitle("Player 1");
var itemPlay2 = form.addListItem().setTitle("Player 2");
var itemMatchFormat = form.addMultipleChoiceItem().setTitle("Match Format");
var sectDoubles = form.addPageBreakItem().setTitle("Doubles Competition");
var itemTeam1Player1 = form.addListItem().setTitle("Team 1: Player 1");
var itemTeam1Player2 = form.addListItem().setTitle("Team 1: Player 2");
var itemTeam2Player1 = form.addListItem().setTitle("Team 2: Player 1");
var itemTeam2Player2 = form.addListItem().setTitle("Team 2: Player 2");
var itemMatchFormat2 = form.addMultipleChoiceItem().setTitle("Match Format");
var sectOneSet = form.addPageBreakItem().setTitle("5-Games / One Set");
var itemSet1 = form.addGridItem().setTitle("Score for first set");
var sectTwoSets = form.addPageBreakItem().setTitle("Two Sets");
var item2SetsSet1 = form.addGridItem().setTitle("Score for first set");
var item2SetsSet2 = form.addGridItem().setTitle("Score for second set");
// Having defined the bare bones, this adds a jump to the end (submitting
// the form). Look carefully which section this is - it's not intuitive!
// The jump is actually defined for section "sectTwoSets", but the
// jump is actioned at the end of the section before this one
sectTwoSets.setGoToPage(FormApp.PageNavigationType.SUBMIT);
// Now flesh out the contents of the various widgets. Routing info for
// the .createChoice methods can now be defined, because all the
// variables defining sections have aleady been defined
itemCompetition.setChoices([
itemCompetition.createChoice("Singles", sectSingles),
itemCompetition.createChoice("Doubles", sectDoubles)]);
itemMatchDate.setRequired(false);
var players = ["Jack", "Gill", "Jim", "Sally"];
itemPlay1.setChoiceValues(players);
itemPlay2.setChoiceValues(players);
itemMatchFormat.setChoices([
itemMatchFormat.createChoice("5 Games", sectOneSet),
itemMatchFormat.createChoice("One Set", sectOneSet),
itemMatchFormat.createChoice("Two Sets", sectTwoSets)]);
itemTeam1Player1.setChoiceValues(players);
itemTeam1Player2.setChoiceValues(players);
itemTeam2Player1.setChoiceValues(players);
itemTeam2Player2.setChoiceValues(players);
itemMatchFormat2.setChoices([
itemMatchFormat2.createChoice("5 Games", sectOneSet),
itemMatchFormat2.createChoice("One Set", sectOneSet),
itemMatchFormat2.createChoice("Two Sets", sectTwoSets)]);
itemSet1.setRows(["Player 1", "Player 2"])
.setColumns(["0", "1", "2", "3", "4", "5", "6", "7"]);
item2SetsSet1.setRows(["Team 1", "Team 2"])
.setColumns(["0", "1", "2", "3", "4", "5", "6", "7"]);
item2SetsSet2.setRows(["Team 1", "Team 2"])
.setColumns(["0", "1", "2", "3", "4", "5", "6", "7"]);
}