Stay organized with collections Save and categorize content based on your preferences.
FormAppAllows a script to open an existing Form
or create a new one.
// Open a form by ID. const existingForm = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); // Create and open a form. const newForm = FormApp.create('Form Name');Detailed documentation
create(title)
Creates and returns a new Form
. Throws an exception if the given title is null
or empty.
// Create and open a form. const form = FormApp.create('Form Name');Parameters Name Type Description
title
String
The name of the new form. Return
Form
— The new form.
Error
— if the given title is null
or empty
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms
create(title, isPublished)
Creates and returns a new Form
in the requested publish state. Throws an exception if the given title is null
or empty.
// Create, publish and open a form. const form = FormApp.create('Form Name', true);Parameters Name Type Description
title
String
The name of the new form. isPublished
Boolean
Whether the form should be published. Return
Form
— The new form.
Error
— if the given title is null
or empty
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms
createCheckboxGridValidation()
createCheckboxValidation()
createFeedback()
Returns an instance of a QuizFeedbackBuilder which can be used to set feedback on a gradeable Item
.
createParagraphTextValidation()
getActiveForm()
Returns the form to which the script is container-bound. To interact with forms to which the script is not container-bound, use openById(id)
or openByUrl(url)
instead.
// Get the form to which this script is bound. const form = FormApp.getActiveForm();Return
Form
— the form to which the script is bound, or null
if the script is not bound to a form
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms.currentonly
https://www.googleapis.com/auth/forms
getUi()
Returns an instance of the form editor's user-interface environment that allows the script to add features like menus, dialogs, and sidebars. A script can only interact with the UI for the current instance of an open form editor (not the view that a respondent sees), and only if the script is bound to the form. For more information, see the guides to menus and dialogs and sidebars.
// Add a custom menu to the active form, including a separator and a sub-menu. function onOpen(e) { FormApp.getUi() .createMenu('My Menu') .addItem('My menu item', 'myFunction') .addSeparator() .addSubMenu( FormApp.getUi() .createMenu('My sub-menu') .addItem('One sub-menu item', 'mySecondFunction') .addItem('Another sub-menu item', 'myThirdFunction'), ) .addToUi(); }Return
Ui
— an instance of this form's user-interface environment
openById(id)
Returns the Form
with the specified ID. Throws an exception if the ID is invalid or the user does not have permission to open the form.
// Open a form by ID. const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');Parameters Name Type Description
id
String
the ID of the form to open Return
Form
— the form with the given ID
Error
— if the given ID is invalid or the user does not have sufficient permissions
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms
openByUrl(url)
Returns the Form
with the specified URL. Throws an exception if the URL is invalid or the user does not have permission to open the form.
// Open a form by URL. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/1234567890abcdefghijklmnopqrstuvwxyz_a1b2c3/edit', );Parameters Name Type Description
url
String
the URL of the form to open Return
Form
— the form with the given URL
Error
— if the given URL is invalid or the user does not have sufficient permissions
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/forms
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-08 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-08 UTC."],[[["FormApp enables scripts to interact with Google Forms, allowing for the creation and modification of forms and their elements."],["It provides methods to create new forms, open existing ones by ID or URL, and access the form's user interface for customization."],["FormApp offers a variety of properties and methods to manage form items, responses, and validation rules for different question types."],["It includes features to programmatically control form behavior, such as navigation, feedback, and response destinations."],["Authorization with specific Google scopes is required for scripts utilizing FormApp functionalities."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4