Class Choice

  • A Choice represents a single option within form items like CheckboxItem, ListItem, or MultipleChoiceItem.

  • ThegetGotoPage() method retrieves the PageBreakItem set as a GO_TO_PAGE destination for a choice in a MultipleChoiceItem.

  • ThegetPageNavigationType() method gets the PageNavigationType associated with a choice in a MultipleChoiceItem.

  • ThegetValue() method returns the string label that respondents see for a choice.

  • TheisCorrectAnswer() method indicates if a choice is marked as a correct answer in a quiz form.

Choice

A single choice associated with a type ofItem that supports choices, likeCheckboxItem,ListItem, orMultipleChoiceItem.

// Create a new form and add a multiple-choice item.constform=FormApp.create('Form Name');constitem=form.addMultipleChoiceItem();item.setTitle('Do you prefer cats or dogs?').setChoices([item.createChoice('Cats',FormApp.PageNavigationType.CONTINUE),item.createChoice('Dogs',FormApp.PageNavigationType.RESTART),]);// Add another page because navigation has no effect on the last page.form.addPageBreakItem().setTitle('You chose well!');// Log the navigation types that each choice results in.constchoices=item.getChoices();for(leti=0;i <choices.length;i++){Logger.log('If the respondent chooses "%s", the form will %s.',choices[i].getValue(),choices[i].getPageNavigationType(),);}

Methods

MethodReturn typeBrief description
getGotoPage()PageBreakItemGets thePageBreakItem set as aGO_TO_PAGE destinationif the responder selects this choice and completes the current page.
getPageNavigationType()PageNavigationTypeGets thePageNavigationType that occurs if the responder selects this choice andcompletes the current page.
getValue()StringGets the choice's value, which respondents see as a label when viewing the form.
isCorrectAnswer()BooleanGets whether the choice is a correct answer for the question.

Detailed documentation

getGotoPage()

Gets thePageBreakItem set as aGO_TO_PAGE destinationif the responder selects this choice and completes the current page. This method applies onlyto choices associated withMultipleChoiceItems; for other choices,it returnsnull.

Return

PageBreakItem — theGO_TO_PAGE destination for this choice, ornull if there is none

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getPageNavigationType()

Gets thePageNavigationType that occurs if the responder selects this choice andcompletes the current page. This method applies only to choices associated withMultipleChoiceItems; for other choices, it returnsnull.

Return

PageNavigationType — the navigation action for this choice, ornull if there is none

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getValue()

Gets the choice's value, which respondents see as a label when viewing the form.

Return

String — the choice's value

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isCorrectAnswer()

Gets whether the choice is a correct answer for the question. This method only applies toquestions that are part of a quiz; for non-quiz forms, it returns false.

Return

Boolean — Whether the choice is a correct answer.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.