// 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(),);}
Obtiene si la opción es una respuesta correcta para la pregunta.
Documentación detallada
getGotoPage()
Obtiene el PageBreakItem establecido como destino GO_TO_PAGE si el encuestado selecciona esta opción y completa la página actual. Este método solo se aplica a las opciones asociadas con MultipleChoiceItems. Para otras opciones, muestra null.
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
getPageNavigationType()
Obtiene el PageNavigationType que se produce si el encuestado selecciona esta opción y completa la página actual. Este método solo se aplica a las opciones asociadas con MultipleChoiceItems. Para otras opciones, muestra null.
Volver
PageNavigationType: Es la acción de navegación para esta opción o null si no hay ninguna.
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
getValue()
Obtiene el valor de la opción, que los encuestados ven como una etiqueta cuando ven el formulario.
Volver
String: Es el valor de la opción.
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
isCorrectAnswer()
Obtiene si la opción es una respuesta correcta para la pregunta. Este método solo se aplica a las preguntas que forman parte de un cuestionario. En el caso de los formularios que no son de cuestionarios, muestra un valor falso.
Volver
Boolean: Indica si la opción es una respuesta correcta.
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003eA Choice object represents a single selection option within Google Forms items like checkboxes, lists, and multiple-choice questions.\u003c/p\u003e\n"],["\u003cp\u003eChoices can be associated with specific navigation actions, like continuing to the next page or restarting the form, using \u003ccode\u003ePageNavigationType\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a choice's display value (what the user sees) and determine if it's marked as a correct answer (for quizzes) using dedicated methods.\u003c/p\u003e\n"],["\u003cp\u003eChoice objects are integral for defining response options and controlling form flow based on user selections.\u003c/p\u003e\n"]]],[],null,["Choice\n\nA single choice associated with a type of [Item](/apps-script/reference/forms/item) that supports choices, like [CheckboxItem](/apps-script/reference/forms/checkbox-item), [ListItem](/apps-script/reference/forms/list-item), or [MultipleChoiceItem](/apps-script/reference/forms/multiple-choice-item).\n\n```javascript\n// Create a new form and add a multiple-choice item.\nconst form = FormApp.create('Form Name');\nconst item = form.addMultipleChoiceItem();\nitem.setTitle('Do you prefer cats or dogs?').setChoices([\n item.createChoice('Cats', FormApp.PageNavigationType.CONTINUE),\n item.createChoice('Dogs', FormApp.PageNavigationType.RESTART),\n]);\n\n// Add another page because navigation has no effect on the last page.\nform.addPageBreakItem().setTitle('You chose well!');\n\n// Log the navigation types that each choice results in.\nconst choices = item.getChoices();\nfor (let i = 0; i \u003c choices.length; i++) {\n Logger.log(\n 'If the respondent chooses \"%s\", the form will %s.',\n choices[i].getValue(),\n choices[i].getPageNavigationType(),\n );\n}\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [getGotoPage()](#getGotoPage()) | [PageBreakItem](/apps-script/reference/forms/page-break-item) | Gets the [PageBreakItem](/apps-script/reference/forms/page-break-item) set as a [GO_TO_PAGE](/apps-script/reference/forms/page-navigation-type) destination if the responder selects this choice and completes the current page. |\n| [getPageNavigationType()](#getPageNavigationType()) | [PageNavigationType](/apps-script/reference/forms/page-navigation-type) | Gets the [PageNavigationType](/apps-script/reference/forms/page-navigation-type) that occurs if the responder selects this choice and completes the current page. |\n| [getValue()](#getValue()) | `String` | Gets the choice's value, which respondents see as a label when viewing the form. |\n| [isCorrectAnswer()](#isCorrectAnswer()) | `Boolean` | Gets whether the choice is a correct answer for the question. |\n\nDetailed documentation \n\n`get``Goto``Page()` \nGets the [PageBreakItem](/apps-script/reference/forms/page-break-item) set as a [GO_TO_PAGE](/apps-script/reference/forms/page-navigation-type) destination\nif the responder selects this choice and completes the current page. This method applies only\nto choices associated with [MultipleChoiceItems](/apps-script/reference/forms/multiple-choice-item); for other choices,\nit returns `null`.\n\nReturn\n\n\n[PageBreakItem](/apps-script/reference/forms/page-break-item) --- the [GO_TO_PAGE](/apps-script/reference/forms/page-navigation-type) destination for this choice, or `null` if there is none\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`get``Page``Navigation``Type()` \nGets the [PageNavigationType](/apps-script/reference/forms/page-navigation-type) that occurs if the responder selects this choice and\ncompletes the current page. This method applies only to choices associated with [MultipleChoiceItems](/apps-script/reference/forms/multiple-choice-item); for other choices, it returns `null`.\n\nReturn\n\n\n[PageNavigationType](/apps-script/reference/forms/page-navigation-type) --- the navigation action for this choice, or `null` if there is none\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`get``Value()` \nGets the choice's value, which respondents see as a label when viewing the form.\n\nReturn\n\n\n`String` --- the choice's value\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`\n\n*** ** * ** ***\n\n`is``Correct``Answer()` \nGets whether the choice is a correct answer for the question. This method only applies to\nquestions that are part of a quiz; for non-quiz forms, it returns false.\n\nReturn\n\n\n`Boolean` --- Whether the choice is a correct answer.\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/forms.currentonly`\n- `https://www.googleapis.com/auth/forms`"]]