Choice

A single choice associated with a type of `https://developers.google.com/apps-script/reference/forms/item` that supports choices, like `https://developers.google.com/apps-script/reference/forms/checkbox-item`, `https://developers.google.com/apps-script/reference/forms/list-item`, or `https://developers.google.com/apps-script/reference/forms/multiple-choice-item`.

```javascript
// Create a new form and add a multiple-choice item.
const form = FormApp.create('Form Name');
const item = 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.
const choices = item.getChoices();
for (let i = 0; i < choices.length; i++) {
  Logger.log(
      'If the respondent chooses "%s", the form will %s.',
      choices[i].getValue(),
      choices[i].getPageNavigationType(),
  );
}
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/forms/choice#getGotoPage()` | `https://developers.google.com/apps-script/reference/forms/page-break-item` | Gets the `https://developers.google.com/apps-script/reference/forms/page-break-item` set as a `https://developers.google.com/apps-script/reference/forms/page-navigation-type` destination if the responder selects this choice and completes the current page. |
| `https://developers.google.com/apps-script/reference/forms/choice#getPageNavigationType()` | `https://developers.google.com/apps-script/reference/forms/page-navigation-type` | Gets the `https://developers.google.com/apps-script/reference/forms/page-navigation-type` that occurs if the responder selects this choice and completes the current page. |
| `https://developers.google.com/apps-script/reference/forms/choice#getValue()` | `String` | Gets the choice's value, which respondents see as a label when viewing the form. |
| `https://developers.google.com/apps-script/reference/forms/choice#isCorrectAnswer()` | `Boolean` | Gets whether the choice is a correct answer for the question. |

## Detailed documentation

### `getGotoPage()`

Gets the `https://developers.google.com/apps-script/reference/forms/page-break-item` set as a `https://developers.google.com/apps-script/reference/forms/page-navigation-type` destination
if the responder selects this choice and completes the current page. This method applies only
to choices associated with `https://developers.google.com/apps-script/reference/forms/multiple-choice-item`; for other choices,
it returns `null`.

#### Return


`https://developers.google.com/apps-script/reference/forms/page-break-item` --- the `https://developers.google.com/apps-script/reference/forms/page-navigation-type` destination for this choice, or `null` if there is none

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/forms.currentonly`
- `https://www.googleapis.com/auth/forms`

*** ** * ** ***

### `getPageNavigationType()`

Gets the `https://developers.google.com/apps-script/reference/forms/page-navigation-type` that occurs if the responder selects this choice and
completes the current page. This method applies only to choices associated with `https://developers.google.com/apps-script/reference/forms/multiple-choice-item`; for other choices, it returns `null`.

#### Return


`https://developers.google.com/apps-script/reference/forms/page-navigation-type` --- the navigation action for this choice, or `null` if there is none

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 to
questions 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 following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/forms.currentonly`
- `https://www.googleapis.com/auth/forms`