Class Form Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
Formobject in Google Apps Script represents a Google Form and can be accessed or created usingFormApp.The document details numerous methods for the
Formobject, covering adding and managing various item types, controlling editors and responders, and managing responses.Methods are provided to get and set form properties and behaviors like title, description, confirmation message, response destination, and response settings.
The document also lists methods for managing form content structure, permissions, and includes notes on deprecated methods.
A form that contains overall properties and items. Properties include title, settings, and whereresponses are stored. Items include question items like checkboxes or radio items, while layoutitems refer to things like page breaks. Forms can be accessed or created fromForm.
// Open a form by ID and create a new spreadsheet.constform=FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');constss=SpreadsheetApp.create('Spreadsheet Name');// Update form properties via chaining.form.setTitle('Form Name').setDescription('Description of form').setConfirmationMessage('Thanks for responding!').setAllowResponseEdits(true).setAcceptingResponses(false);// Update the form's response destination.form.setDestination(FormApp.DestinationType.SPREADSHEET,ss.getId());
Methods
| Method | Return type | Brief description |
|---|---|---|
add | Checkbox | Appends a new question item, presented as a grid of columns and rows, that allows therespondent to select multiple choices per row from a sequence of checkboxes. |
add | Checkbox | Appends a new question item that allows the respondent to select one or more checkboxes, aswell as an optional "other" field. |
add | Date | Appends a new question item that allows the respondent to indicate a date. |
add | Date | Appends a new question item that allows the respondent to indicate a date and time. |
add | Duration | Appends a new question item that allows the respondent to indicate a length of time. |
add | Form | Adds the given user to the list of editors for theForm. |
add | Form | Adds the given user to the list of editors for theForm. |
add | Form | Adds the given array of users to the list of editors for theForm. |
add | Grid | Appends a new question item, presented as a grid of columns and rows, that allows therespondent to select one choice per row from a sequence of radio buttons. |
add | Image | Appends a new layout item that displays an image. |
add | List | Appends a new question item that allows the respondent to select one choice from a dropdownlist. |
add | Multiple | Adds a new question item that allows the respondent to select one choice from a list of radiobuttons or an optional "other" field. |
add | Page | Adds a new layout item that marks the start of a page. |
add | Paragraph | Adds a new question item that allows the respondent to enter a block of text. |
add | Form | Adds the given user to the list of responders for theForm. |
add | Form | Adds the given user to the list of responders for theForm. |
add | Form | Adds the given array of users to the list of responders for theForm. |
add | Rating | Appends a new question item that allows the respondent to give a rating. |
add | Scale | Appends a new question item that allows the respondent to choose one option from a numberedsequence of radio buttons. |
add | Section | Appends a new layout item that visually indicates the start of a section. |
add | Text | Appends a new question item that allows the respondent to enter a single line of text. |
add | Time | Appends a new question item that allows the respondent to indicate a time of day. |
add | Video | Appends a new layout item that displays a video. |
can | Boolean | Determines whether the form displays a link to edit a response after submitting it. |
collects | Boolean | Determines whether the form collects respondents' email addresses. |
create | Form | Creates a new response to the form. |
delete | Form | Deletes all submitted responses from the form's response store. |
delete | void | Deletes the item at a given index among all the items in the form. |
delete | void | Deletes the given item. |
delete | Form | Deletes a single response from the form's response store. |
get | String | Gets the form's confirmation message. |
get | String | Gets the custom message that is displayed if the form is not accepting responses, or an emptystring if no custom message is set. |
get | String | Gets the form's description. |
get | String | Gets the ID of the form's response destination. |
get | Destination | Gets the type of the form's response destination. |
get | String | Gets the URL that can be used to access the form's edit mode. |
get | User[] | Gets the list of editors for thisForm. |
get | String | Gets the ID of the form. |
get | Item | Gets the item with a given ID. |
get | Item[] | Gets an array of all items in the form. |
get | Item[] | Gets an array of all items of a given type. |
get | User[] | Gets the list of responders for thisForm. |
get | String | Gets the URL that can be used to respond to the form. |
get | Form | Gets a single form response based on its response ID. |
get | Form | Gets an array of all of the form's responses. |
get | Form | Gets an array of all of the form's responses after a given date and time. |
get | Boolean | Determines whether the order of the questions on each page of the form is randomized. |
get | String | Gets the URL that can be used to view a summary of the form's responses. |
get | String | Gets the form's title. |
has | Boolean | Determines whether the form allows only one response per respondent. |
has | Boolean | Determines whether the form displays a progress bar. |
has | Boolean | Determines whether the form displays a link to submit another response after a respondentcompletes the form. |
is | Boolean | Determines whether the form is currently accepting responses. |
is | Boolean | Determines whether the form is published. |
is | Boolean | Determines whether the form displays a link to view a summary of responses after a respondentcompletes the form. |
is | Boolean | Determines whether the form is a quiz. |
move | Item | Moves an item at a given index among all the items in the form to another given index. |
move | Item | Moves a given item to a given index among all the items in the form. |
remove | Form | Unlinks the form from its current response destination. |
remove | Form | Removes the given user from the list of editors for theForm. |
remove | Form | Removes the given user from the list of editors for theForm. |
remove | Form | Removes the given user from the list of responders for theForm. |
remove | Form | Removes the given user from the list of responders for theForm. |
set | Form | Sets whether the form is currently accepting responses. |
set | Form | Sets whether the form displays a link to edit a response after submitting it. |
set | Form | Sets whether the form collects respondents' email addresses. |
set | Form | Sets the form's confirmation message. |
set | Form | Sets the message to display if the form is not accepting responses. |
set | Form | Sets the form's description. |
set | Form | Sets the destination where form responses are saved. |
set | Form | Sets whether the form is a quiz. |
set | Form | Sets whether the form allows only one response per respondent. |
set | Form | Sets whether the form has a progress bar. |
set | Form | Sets whether the form is published. |
set | Form | Sets whether the form displays a link to view a summary of responses after a respondent submitsthe form. |
set | Form | Sets whether the form displays a link to submit another response after a respondent completesthe form. |
set | Form | Sets whether the order of the questions on each page of the form is randomized. |
set | Form | Sets the form's title. |
shorten | String | Converts a long URL for a form to a short URL. |
submit | Form | Submits grades for the given FormResponses. |
supports | Boolean | Determines whether the form supports publishing. |
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| Boolean | Determines whether the form requires respondents to log in to an account in the same domain ora subdomain before responding. |
| Form | Sets whether the form requires respondents to log in to an account in the same domain or asubdomain before responding. |
Detailed documentation
addCheckboxGridItem()
Appends a new question item, presented as a grid of columns and rows, that allows therespondent to select multiple choices per row from a sequence of checkboxes.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a checkbox grid item.constitem=form.addCheckboxGridItem();item.setTitle('Where did you celebrate New Year\'s?');// Sets the grid's rows and columns.item.setRows(['New York','San Francisco','London']).setColumns(['2014','2015','2016','2017']);
Return
Checkbox — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addCheckboxItem()
Appends a new question item that allows the respondent to select one or more checkboxes, aswell as an optional "other" field.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a checkbox item.constitem=form.addCheckboxItem();// Sets the title of the checkbox item to 'Do you prefer cats or dogs?'item.setTitle('Do you prefer cats or dogs?');// Sets the choices.item.setChoiceValues(['Cats','Dogs']);
Return
Checkbox — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addDateItem()
Appends a new question item that allows the respondent to indicate a date.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a date item.constitem=form.addDateItem();// Sets the title to 'When were you born?'item.setTitle('When were you born?');// Sets the description for the date item.item.setHelpText('Some helper text.');
Return
Date — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addDateTimeItem()
Appends a new question item that allows the respondent to indicate a date and time.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a question with date and time inputs.constitem=form.addDateTimeItem();// Sets the title to 'When were you born?'item.setTitle('When were you born?');// Sets the question as required.item.setRequired(true);
Return
Date — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addDurationItem()
Appends a new question item that allows the respondent to indicate a length of time.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a question with a duration input.constitem=form.addDurationItem();// Sets the title to 'How long can you hold your breath?'item.setTitle('How long can you hold your breath?');// Sets the question as required.item.setRequired(true);
Return
Duration — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addEditor(emailAddress)
Adds the given user to the list of editors for theForm. If the user was already on thelist of viewers or responders, this method promotes the user out of the list.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Adds editor to the form.// TODO(developer): replace the emailAddress.form.addEditor('editor@uni.edu');
Parameters
| Name | Type | Description |
|---|---|---|
email | String | The email address of the user to add. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addEditor(user)
Adds the given user to the list of editors for theForm. If the user was already on thelist of viewers or responders, this method promotes the user out of the list.
// Opens the Forms file by its URL.// TODO(developer): Replace the URL with your own.constoldForm=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Gets the editors from the old form.constusers=oldForm.getEditors();// Creates a new form.constnewForm=FormApp.create('New form');// Adds the editors to a new form.users.forEach(user=>newForm.addEditor(user));
Parameters
| Name | Type | Description |
|---|---|---|
user | User | A representation of the user to add. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addEditors(emailAddresses)
Adds the given array of users to the list of editors for theForm. If any of the userswere already on the list of viewers, this method promotes them out of the list of viewers.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Adds editors to the form.// TODO(developer): replace the emailAddress.form.addPublishedReaders(['editor1@uni.edu','editor2@uni.edu']);
Parameters
| Name | Type | Description |
|---|---|---|
email | String[] | An array of email addresses of the users to add. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addGridItem()
Appends a new question item, presented as a grid of columns and rows, that allows therespondent to select one choice per row from a sequence of radio buttons.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a multiple choice grid.constitem=form.addGridItem();// Sets the title to 'Rate your interests.'item.setTitle('Rate your interests');// Sets the grid's rows and columns.item.setRows(['Cars','Computers','Celebrities']).setColumns(['Boring','So-so','Interesting']);
Return
Grid — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addImageItem()
Appends a new layout item that displays an image.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds an image item.constitem=form.addImageItem();// Gets the Google icon to use as the image.constimg=UrlFetchApp.fetch('https://fonts.gstatic.com/s/i/productlogos/googleg/v6/web-24dp/logo_googleg_color_1x_web_24dp.png',);// Sets the image, title, and description for the item.item.setTitle('Google icon').setHelpText('Google icon').setImage(img);
Return
Image — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addListItem()
Appends a new question item that allows the respondent to select one choice from a dropdownlist.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a dropdown list to the form.constitem=form.addListItem();// Sets the title to 'Do you prefer cats or dogs?'item.setTitle('Do you prefer cats or dogs?');// Sets the description to 'This is description text...'item.setHelpText('This is description text...');// Creates and adds choices to the dropdown list.item.setChoices([item.createChoice('dog'),item.createChoice('cat')]);
Return
List — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addMultipleChoiceItem()
Adds a new question item that allows the respondent to select one choice from a list of radiobuttons or an optional "other" field.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a multiple choice item to the form.constitem=form.addMultipleChoiceItem();// Sets the title.item.setTitle('What is your favorite ice cream flavor?');// Creates some choice items.constvanilla=item.createChoice('vanilla');constchocolate=item.createChoice('chocolate');conststrawberry=item.createChoice('strawberry');// Sets the choices.item.setChoices([vanilla,chocolate,strawberry]);
Return
Multiple — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addPageBreakItem()
Adds a new layout item that marks the start of a page.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds page break items to create a second and third page for the form.constpageTwo=form.addPageBreakItem();constpageThree=form.addPageBreakItem();// Sets the titles for the pages.pageTwo.setTitle('Page two');pageThree.setTitle('Page three');// Upon completion of the first page, sets the form to navigate to the third// page.pageTwo.setGoToPage(pageThree);// Upon completion of the second page, sets the form to navigate back to the// first page.pageThree.setGoToPage(FormApp.PageNavigationType.RESTART);
Return
Page — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addParagraphTextItem()
Adds a new question item that allows the respondent to enter a block of text.
// Opens the form by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds the paragraph text item.constitem=form.addParagraphTextItem();// Sets the title to 'What is your address?'item.setTitle('What is your address?');
Return
Paragraph — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addPublishedReader(emailAddress)
Adds the given user to the list of responders for theForm. If the user was already onthe list of editors or viewers, this method has no effect.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Adds responder to the form.// TODO(developer): replace the emailAddress.form.addPublishedReader('responder@uni.edu');
Parameters
| Name | Type | Description |
|---|---|---|
email | String | The email address of the user to add. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addPublishedReader(user)
Adds the given user to the list of responders for theForm. If the user was already onthe list of editors or viewers, this method has no effect.
// Opens the Forms file by its URL.// TODO(developer): Replace the URL with your own.constoldForm=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Gets the responders from the old form.constusers=oldForm.getPublishedReaders();// Creates a new form.constnewForm=FormApp.create('New form');// Adds the responders to a new form.users.forEach(user=>newForm.addPublishedReader(user));
Parameters
| Name | Type | Description |
|---|---|---|
user | User | A representation of the user to add. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addPublishedReaders(emailAddresses)
Adds the given array of users to the list of responders for theForm. If the user wasalready on the list of editors or viewers, this method has no effect.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Adds responders to the form.// TODO(developer): replace the emailAddress.form.addPublishedReaders(['responder1@uni.edu','responder2@uni.edu']);
Parameters
| Name | Type | Description |
|---|---|---|
email | String[] | An array of email addresses of the users to add. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addRatingItem()
Appends a new question item that allows the respondent to give a rating.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds the rating item.constitem=form.addRatingItem();
Return
Rating — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addScaleItem()
Appends a new question item that allows the respondent to choose one option from a numberedsequence of radio buttons.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds the scale item.constitem=form.addScaleItem();// Sets the title of the scale item to 'Choose a number.'item.setTitle('Choose a number');// Sets the scale to 1-5.item.setBounds(1,5);// Sets the label for the lower and upper bounds.item.setLabels('Lowest','Highest');
Return
Scale — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addSectionHeaderItem()
Appends a new layout item that visually indicates the start of a section.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds the section heading item.constitem=form.addSectionHeaderItem();// Sets the title to 'Title of new section.'item.setTitle('Title of new section');// Sets the description.item.setHelpText('Description of new section');
Return
Section — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addTextItem()
Appends a new question item that allows the respondent to enter a single line of text.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a single-line text item.constitem=form.addTextItem();// Sets the title to 'What is your name?'item.setTitle('What is your name?');
Return
Text — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addTimeItem()
Appends a new question item that allows the respondent to indicate a time of day.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a question with a time input.constitem=form.addTimeItem();// Sets the title to 'What time do you usually wake up in the morning?'item.setTitle('What time do you usually wake up in the morning?');
Return
Time — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
addVideoItem()
Appends a new layout item that displays a video.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Adds a video item.constitem=form.addVideoItem();// Sets the title, description, and video.item.setTitle('YouTube video').setHelpText('Send content automatically via Google Sheets and Apps Script').setVideoUrl('https://youtu.be/xxgQr-jSu9o');// Sets the alignment to the center.item.setAlignment(FormApp.Alignment.CENTER);
Return
Video — The newly created item.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
canEditResponse()
Determines whether the form displays a link to edit a response after submitting it.
Regardless of this setting, the methodForm allows ascript author who has edit access to the form to generate a URL that can be used to edit aresponse.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Checks if the form displays a link to edit a response after submitting it.// The default is false. To let people edit their responses, use// form.setAllowResponseEdits(true).constedit=form.canEditResponse();// If the form doesn't let people edit responses, logs false to the console.console.log(edit);
Return
Boolean —true if the form displays an "Edit your response" link;false if it doesn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
collectsEmail()
Determines whether the form collects respondents' email addresses.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to not collect respondents' email addresses.form.setCollectEmail(false);// Checks whether the form collects respondents' email addresses and logs it to// the console.constbool=form.collectsEmail();console.log(bool);
Return
Boolean —true if the form collects email addresses;false if it doesn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
createResponse()
Creates a new response to the form. To answer a question item, create anItemfrom the item, then attach it to this form response by callingForm. To save the assembled response, callForm.
Return
Form — The newly created form response.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
deleteAllResponses()
Deletes all submitted responses from the form's response store. This method does not deletecopies of responses stored in an external response destination (like a spreadsheet), but doesclear the form's summary view.
Beware: this method is irreversible.
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
deleteItem(index)
Deletes the item at a given index among all the items in the form. Throws a scripting exceptionif no item exists at the given index.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets all the items from the form.constitems=form.getItems();// Finds the index of a paragraph text item and deletes it by the item's index.constindex=items.findIndex((item)=>item.getType()===FormApp.ItemType.PARAGRAPH_TEXT,);if(index!==-1){form.deleteItem(index);}
Parameters
| Name | Type | Description |
|---|---|---|
index | Integer | The index of the item among all the items in the form. |
Throws
Error — if no item exists at the given index
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
deleteItem(item)
Deletes the given item. Throws a scripting exception if the item has already been deleted.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets all of the items from the form.constitems=form.getItems();// Finds a paragraph text item and deletes it.constitem=items.find((item)=>item.getType()===FormApp.ItemType.PARAGRAPH_TEXT,);if(item){form.deleteItem(item);}
Parameters
| Name | Type | Description |
|---|---|---|
item | Item | The item to be deleted. |
Throws
Error — if the item does not exist in the form
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
deleteResponse(responseId)
Deletes a single response from the form's response store. This method does not delete copies ofresponses stored in an external response destination (like a spreadsheet), but does remove theresponse from the form's summary view. The response ID can be retrieved withForm.
Warning: This method is irreversible.
Parameters
| Name | Type | Description |
|---|---|---|
response | String | The ID of the form response to delete. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getConfirmationMessage()
Gets the form's confirmation message.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the confirmation message to display after someone submits the form.form.setConfirmationMessage('You successfully submitted the form.');// Gets the confirmation message and logs it to the console.constmessage=form.getConfirmationMessage();console.log(message);
Return
String — The form's confirmation message.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getCustomClosedFormMessage()
Gets the custom message that is displayed if the form is not accepting responses, or an emptystring if no custom message is set.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets a custom closed form message to display to the user when the form// no longer accepts responses.form.setCustomClosedFormMessage('The form is no longer accepting responses.');// Gets the custom message set for the form and logs it to the console.constmessage=form.getCustomClosedFormMessage();console.log(message);
Return
String — The custom message to display if the form is not accepting responses, or an empty string if no custom message is set.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getDescription()
Gets the form's description.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form description.form.setDescription('This is the form description.');// Gets the form description and logs it to the console.constdescription=form.getDescription();console.log(description);
Return
String — The form's description.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getDestinationId()
Gets the ID of the form's response destination.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Creates a spreadsheet to use as the response destination.constss=SpreadsheetApp.create('Test_Spreadsheet');// Updates the form's response destination.form.setDestination(FormApp.DestinationType.SPREADSHEET,ss.getId());// Gets the ID of the form's response destination and logs it to the console.constdestinationId=form.getDestinationId();console.log(destinationId);
Return
String — The ID of the form's response destination.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getDestinationType()
Gets the type of the form's response destination.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc1234556/edit',);// Gets the type of the form's response destination and logs it to the console.constdestinationType=form.getDestinationType().name();console.log(destinationType);
Return
Destination — The type of the form's response destination.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getEditUrl()
Gets the URL that can be used to access the form's edit mode.
// Opens the form by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the URL that accesses the form's edit mode and logs it to the console.consturl=form.getEditUrl();console.log(url);
Return
String — The URL to edit the form.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getEditors()
getId()
Gets the ID of the form.
// Opens the form by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the ID of the form and logs it to the console.constid=form.getId();console.log(id);
Return
String — The ID of the form.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getItemById(id)
Gets the item with a given ID. Returnsnull if the ID does not correspond to an item inthe form.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the ID of the first item on the form.constitemId=form.getItems()[0].getId();// Gets the item from the ID.constitem=form.getItemById(itemId);// Gets the name of the item type and logs it to the console.consttype=item.getType().name();console.log(type);
Parameters
| Name | Type | Description |
|---|---|---|
id | Integer | The item's ID. |
Return
Item — The item with the given ID, ornull if the item does not exist in the form.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getItems()
Gets an array of all items in the form.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the list of items in the form.constitems=form.getItems();// Gets the type for each item and logs them to the console.consttypes=items.map((item)=>item.getType().name());console.log(types);
Return
Item[] — An array of all items in the form.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getItems(itemType)
Gets an array of all items of a given type.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets a list of all checkbox items on the form.constitems=form.getItems(FormApp.ItemType.CHECKBOX);// Gets the title of each checkbox item and logs them to the console.constcheckboxItemsTitle=items.map((item)=>item.asCheckboxItem().getTitle(),);console.log(checkboxItemsTitle);
Parameters
| Name | Type | Description |
|---|---|---|
item | Item | The type of items to retrieve. |
Return
Item[] — An array of all items of that type.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getPublishedReaders()
Gets the list of responders for thisForm.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Gets the responders for the form.constusers=form.getPublishedReaders();users.forEach(user=>console.log(user.getEmail()));
Return
User[] — An array of users with responder permission.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getPublishedUrl()
Gets the URL that can be used to respond to the form.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the URL to respond to the form and logs it to the console.consturl=form.getPublishedUrl();console.log(url);
Return
String — The URL to respond to the form.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getResponse(responseId)
Gets a single form response based on its response ID. Response IDs can be retrieved fromForm.
Parameters
| Name | Type | Description |
|---|---|---|
response | String | The ID for the form response. |
Return
Form — The form response.
Throws
Error — if the response does not exist
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getResponses()
Gets an array of all of the form's responses.
Return
Form — An array of all of the form's responses.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getResponses(timestamp)
Gets an array of all of the form's responses after a given date and time.
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | Date | The earliest date and time for which form responses should be returned. |
Return
Form — The list of form responses.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getShuffleQuestions()
Determines whether the order of the questions on each page of the form is randomized.
Return
Boolean —true if the order of the questions on each page of the form is randomized;false if not.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getSummaryUrl()
Gets the URL that can be used to view a summary of the form's responses. Unlessset is set totrue, only the users with edit permission to theform is able to access the URL.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// Opens the form by its URL.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the URL to view a summary of the form's responses and logs it to the// console.consturl=form.getSummaryUrl();console.log(url);
Return
String — The URL to view a summary of responses.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
getTitle()
Gets the form's title.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the title of the form to 'For_Testing.'form.setTitle('For_Testing');// Gets the title of the form and logs it to the console.consttitle=form.getTitle();console.log(title);
Return
String — The form's title.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
hasLimitOneResponsePerUser()
Determines whether the form allows only one response per respondent. If the value istrue, the script cannot submit form responses at all.
Return
Boolean —true if the form allows only one response per respondent;false if not.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
hasProgressBar()
Determines whether the form displays a progress bar.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// Opens the form by its URL.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Displays the progress bar on the form.form.setProgressBar(true);// Checks if the form displays a progress bar and logs it to the console.console.log(form.hasProgressBar());
Return
Boolean —true if the form displays a progress bar;false if it doesn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
hasRespondAgainLink()
Determines whether the form displays a link to submit another response after a respondentcompletes the form.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to display a link to submit another// response after someone submits the form.form.setShowLinkToRespondAgain(true);// Checks if the form displays a 'Submit another response' link and logs it to// the console.console.log(form.hasRespondAgainLink());
Return
Boolean —true if the form displays a "Submit another response" link;false if it doesn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
isAcceptingResponses()
Determines whether the form is currently accepting responses. This is overwritten when theform's publishing state is changed.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to accept responses.form.setAcceptingResponses(true);// Checks if the form is accepting responses or not and logs it to the console.constaccepting=form.isAcceptingResponses();console.log(accepting);
Return
Boolean —true if the form is accepting responses;false if it isn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
isPublished()
Determines whether the form is published.
This feature is only available for forms that support publishing. Usesupports to check if the form supports publishing.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Checks whether the form is published or not and logs it to the console.console.log(form.isPublished());
Return
Boolean —true if the form is published;false if it isn't.
Throws
Error — if called on unsupported forms.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
isPublishingSummary()
Determines whether the form displays a link to view a summary of responses after a respondentcompletes the form.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to display a link to a summary of// the responses after someone submits the form.form.setPublishingSummary(true);// Checks if the form displays a "See previous responses" link and logs it to// the console.constpublishingLink=form.isPublishingSummary();console.log(publishingLink);
Return
Boolean —true if the form displays a "See previous responses" link;false if it doesn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
isQuiz()
Determines whether the form is a quiz.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form as a quiz.form.setIsQuiz(true);// Checks if the form is a quiz or not and logs it to the console.console.log(form.isQuiz());
Return
Boolean —true if the form is accepting responses;false if it isn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
moveItem(from, to)
Moves an item at a given index among all the items in the form to another given index. Throws ascripting exception if theto index is out of bounds.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Moves the first item to be the last item.form.moveItem(0,form.getItems().length-1);
Parameters
| Name | Type | Description |
|---|---|---|
from | Integer | The current index of the item among all the items in the form. |
to | Integer | The new index for the item among all the items in the form. |
Return
Item — The item that was moved.
Throws
Error — if either index is out of bounds.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
moveItem(item, toIndex)
Moves a given item to a given index among all the items in the form. Throws a scriptingexception if the given index is out of bounds.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Gets the first item.constitem=form.getItems()[0];// Moves the item to be the last item.form.moveItem(item,form.getItems().length-1);
Parameters
| Name | Type | Description |
|---|---|---|
item | Item | The item to move. |
to | Integer | The new index for the item among all the items in the form. |
Return
Item — The item that was moved.
Throws
Error — if the index is out of bounds.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
removeDestination()
Unlinks the form from its current response destination. The unlinked former destination stillretains a copy of all previous responses. All forms, including those that do not have adestination set explicitly,save acopy of responses in the form's response store. If the form does not currently have aresponse destination, this method has no effect.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Opens a spreadsheet to use for the response destination.// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);// Updates the form's response destination to the spreadsheet.form.setDestination(FormApp.DestinationType.SPREADSHEET,ss.getId());// Unlinks the form from the spreadsheet.form.removeDestination();
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
removeEditor(emailAddress)
Removes the given user from the list of editors for theForm. This method doesn't blockusers from accessing theForm if they belong to a class of users who have generalaccess—for example, if theForm is shared with the user's entire domain, or iftheForm is in a shared drive that the user can access.
For Drive files, this also removes the user from the list of viewers and responders.
// Opens the Forms file by its URL.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Removes the editor from the form.// TODO(developer): replace the emailAddress.form.removeEditor('editor@uni.edu');
Parameters
| Name | Type | Description |
|---|---|---|
email | String | The email address of the user to remove. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
removeEditor(user)
Removes the given user from the list of editors for theForm. This method doesn't blockusers from accessing theForm if they belong to a class of users who have generalaccess—for example, if theForm is shared with the user's entire domain, or iftheForm is in a shared drive that the user can access.
For Drive files, this also removes the user from the list of viewers.
// Opens the Forms file by its URL.// TODO(developer): Replace the URL with your own.constform1=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Gets the editors from the form.constusers=form1.getEditors();// Opens another form.// TODO(developer): Replace the URL with your own.constform2=FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit');// Removes editors from the form.users.forEach(user=>form2.removeEditor(user));
Parameters
| Name | Type | Description |
|---|---|---|
user | User | A representation of the user to remove. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
removePublishedReader(emailAddress)
Removes the given user from the list of responders for theForm. This method doesn'tblock users from accessing theForm if they belong to a class of users who have generalaccess—for example, if theForm is shared with the user's entire domain, or iftheForm is in a shared drive that the user can access.
For Drive files, this also removes the user from the list of viewers and editors.
// Opens the Forms file by its URL.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Removes the responders from the form.// TODO(developer): replace the emailAddress.form.removePublishedReader('responder1@uni.edu');
Parameters
| Name | Type | Description |
|---|---|---|
email | String | The email address of the user to remove. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
removePublishedReader(user)
Removes the given user from the list of responders for theForm. This method doesn'tblock users from accessing theForm if they belong to a class of users who have generalaccess—for example, if theForm is shared with the user's entire domain, or iftheForm is in a shared drive that the user can access.
For Drive files, this also removes the user from the list of viewers and editors.
// Opens the Forms file by its URL.// TODO(developer): Replace the URL with your own.constform1=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Gets the responders from the form.constusers=form1.getPublishedReaders();// Opens another form.// TODO(developer): Replace the URL with your own.constform2=FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit');// Removes responders from the form.users.forEach(user=>form2.removePublishedReader(user));
Parameters
| Name | Type | Description |
|---|---|---|
user | User | A representation of the user to remove. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setAcceptingResponses(enabled)
Sets whether the form is currently accepting responses. The default for new forms istrue. The state is overwritten when the publish state of the form is changed.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to accept responses.form.setAcceptingResponses(true);// Checks whether the form is accepting responses or not and logs it to the// console.console.log(form.isAcceptingResponses());
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form should accept responses;false if it shouldn't. |
Return
Form — ThisForm, for chaining.
Throws
Error — if enabled on an unpublished form.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setAllowResponseEdits(enabled)
Sets whether the form displays a link to edit a response after submitting it. The default fornew forms isfalse.
Regardless of this setting, the methodForm allows ascript author who has edit permission to the form to generate a URL that can be used to edit aresponse.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Shows "Edit your response" link after someone submits the form.form.setAllowResponseEdits(true);// Checks whether the option to edit the form after a user submits it is set to// true or not and logs it to the console.console.log(form.canEditResponse());
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form should display an "Edit your response" link;false if not. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setCollectEmail(collect)
Sets whether the form collects respondents' email addresses. The default for new forms isfalse.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to collect respondents' email addresses.form.setCollectEmail(true);// Checks whether the value is set to true or false and logs it to the console.constcollect=form.collectsEmail();console.log(collect);
Parameters
| Name | Type | Description |
|---|---|---|
collect | Boolean | true if the form should collect email addresses;false if it doesn't. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setConfirmationMessage(message)
Sets the form's confirmation message.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets a custom confirmation message to display after someone submits the form.form.setConfirmationMessage('Your form has been successfully submitted.');// Gets the confirmation message set for the form and logs it to the console.constmessage=form.getConfirmationMessage();console.log(message);
Parameters
| Name | Type | Description |
|---|---|---|
message | String | The form's new confirmation message. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setCustomClosedFormMessage(message)
Sets the message to display if the form is not accepting responses. If no message is set, theform uses a default message.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form to not accept responses.form.setAcceptingResponses(false);// Sets a custom closed form message to display to the user.form.setCustomClosedFormMessage('The form is no longer accepting responses.');// Gets the custom message set for the form and logs it to the console.constmessage=form.getCustomClosedFormMessage();console.log(message);
Parameters
| Name | Type | Description |
|---|---|---|
message | String | The message to display if the form is not accepting responses. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setDescription(description)
Sets the form's description.
Parameters
| Name | Type | Description |
|---|---|---|
description | String | The form's new description. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setDestination(type, id)
Sets the destination where form responses are saved. All forms, including those that do nothave a destination set explicitly,save a copy of responses in the form'sresponse store.
Parameters
| Name | Type | Description |
|---|---|---|
type | Destination | The type of the form's response destination. |
id | String | The ID of the form's response destination. |
Return
Form — ThisForm, for chaining.
Throws
Error — if the given destination ID is invalid
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setIsQuiz(enabled)
Sets whether the form is a quiz. The default for new forms isfalse.
Graded questions are only allowed in Quizzes, so setting this tofalse causes allgrading options to be removed from all questions.
Quiz settings are only available in the new Forms UI; making a form a Quiz opts the forminto using the new UI.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Makes the form a quiz.form.setIsQuiz(true);// Checks whether the form is a quiz or not and logs it to the console.console.log(form.isQuiz());
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if quiz features should be enabled for the form;false if not. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setLimitOneResponsePerUser(enabled)
Sets whether the form allows only one response per respondent. The default for new forms isfalse. If the value is set totrue, the script cannot submit form responses atall.
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form should allow only one response per respondent;false if not. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setProgressBar(enabled)
Sets whether the form has a progress bar. The default for new forms isfalse.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Displays the progress bar on the form.form.setProgressBar(true);// Checks whether the form has a progress bar and logs it to the console.console.log(form.hasProgressBar());
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form displays a progress bar;false if it doesn't. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setPublished(enabled)
Sets whether the form is published. The default for new forms istrue.
This feature is only available for forms that support publishing. Usesupports to check if the form supports publishing.
A form needs to be published for it to be accessible to responders. This method supersedescalls toset.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Publishes the form before sharing it.form.setPublished(true);// Checks whether the form is published or not and logs it to the console.console.log(form.isPublished());
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form should be published,false if not. |
Return
Form — ThisForm, for chaining.
Throws
Error — if called on unsupported forms.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setPublishingSummary(enabled)
Sets whether the form displays a link to view a summary of responses after a respondent submitsthe form. The default for new forms isfalse.
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form should display a "See previous responses" link;false if not. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setShowLinkToRespondAgain(enabled)
Sets whether the form displays a link to submit another response after a respondent completesthe form. The default for new forms istrue.
Parameters
| Name | Type | Description |
|---|---|---|
enabled | Boolean | true if the form should display a "Submit another response" link;false if not. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setShuffleQuestions(shuffle)
Sets whether the order of the questions on each page of the form is randomized.
Parameters
| Name | Type | Description |
|---|---|---|
shuffle | Boolean | true if the order of the questions on each page of the form should be randomized;false if not. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
setTitle(title)
Sets the form's title.
Parameters
| Name | Type | Description |
|---|---|---|
title | String | The form's new title. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
shortenFormUrl(url)
Converts a long URL for a form to a short URL. Throws an exception if the long URL does notbelong to Google Forms.
Parameters
| Name | Type | Description |
|---|---|---|
url | String | The URL to shorten. |
Return
String — A URL in the formhttp://goo.gl/forms/1234.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
submitGrades(responses)
Submits grades for the given FormResponses.
If your code includes anon trigger, callingsubmittriggers theon condition and causes an infinite loop. To prevent theinfinite loop, add code that checks whether grades already exist before callingsubmit.
Parameters
| Name | Type | Description |
|---|---|---|
responses | Form | An array of all of the form's responses. |
Return
Form — ThisForm, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
supportsAdvancedResponderPermissions()
Determines whether the form supports publishing. This method is used to determine whether theset andis methods, and responder permissions,are available.
// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Checks whether the form supports publishing or not and logs it to the// console.console.log(form.supportsAdvancedResponderPermissions());
Return
Boolean —true if the form supports publishing;false if it doesn't.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://www.googleapis.com/auth/forms
Deprecated methods
requiresLogin()
requiresLogin() Deprecated. This function is deprecated and should not be used in new scripts.
Determines whether the form requires respondents to log in to an account in the same domain ora subdomain before responding.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Checks if the form requires respondents to log in to a Google Workspace// account before responding and logs it to the console.constlogin=form.requiresLogin();console.log(login);
Return
Boolean —true if the form requires users to log in;false if it doesn't.
setRequireLogin(requireLogin)
setRequireLogin(requireLogin) Deprecated. This function is deprecated and should not be used in new scripts.
Sets whether the form requires respondents to log in to an account in the same domain or asubdomain before responding. The default for new forms isfalse unless a domainadministrator changes the default.
This feature is available only for forms created by Google Workspace users. Users of othertypes of Google accounts can't be required to log in.
// Opens the Forms file by its URL. If you created your script from within// a Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);// Sets the form so that users must log in to their Google Workspace account.form.setRequireLogin(true);// Checks whether the form requires login or not and logs it to the console.console.log(form.requiresLogin());
Parameters
| Name | Type | Description |
|---|---|---|
require | Boolean | true if the form requires users to log in;false if it doesn't. |
Return
Form — The current form (for chaining).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/forms.currentonlyhttps://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.