Class Form

Form

A form that contains overall properties and items. Properties include title, settings, and where responses are stored. Items include question items like checkboxes or radio items, while layout items refer to things like page breaks. Forms can be accessed or created from FormApp.

// Open a form by ID and create a new spreadsheet.
var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
var ss = 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

MethodReturn typeBrief description
addCheckboxGridItem()CheckboxGridItemAppends a new question item, presented as a grid of columns and rows, that allows the respondent to select multiple choices per row from a sequence of checkboxes.
addCheckboxItem()CheckboxItemAppends a new question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.
addDateItem()DateItemAppends a new question item that allows the respondent to indicate a date.
addDateTimeItem()DateTimeItemAppends a new question item that allows the respondent to indicate a date and time.
addDurationItem()DurationItemAppends a new question item that allows the respondent to indicate a length of time.
addEditor(emailAddress)FormAdds the given user to the list of editors for the Form.
addEditor(user)FormAdds the given user to the list of editors for the Form.
addEditors(emailAddresses)FormAdds the given array of users to the list of editors for the Form.
addGridItem()GridItemAppends a new question item, presented as a grid of columns and rows, that allows the respondent to select one choice per row from a sequence of radio buttons.
addImageItem()ImageItemAppends a new layout item that displays an image.
addListItem()ListItemAppends a new question item that allows the respondent to select one choice from a drop-down list.
addMultipleChoiceItem()MultipleChoiceItemAppends a new question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.
addPageBreakItem()PageBreakItemAppends a new layout item that marks the start of a page.
addParagraphTextItem()ParagraphTextItemAppends a new question item that allows the respondent to enter a block of text.
addScaleItem()ScaleItemAppends a new question item that allows the respondent to choose one option from a numbered sequence of radio buttons.
addSectionHeaderItem()SectionHeaderItemAppends a new layout item that visually indicates the start of a section.
addTextItem()TextItemAppends a new question item that allows the respondent to enter a single line of text.
addTimeItem()TimeItemAppends a new question item that allows the respondent to indicate a time of day.
addVideoItem()VideoItemAppends a new layout item that displays a video.
canEditResponse()BooleanDetermines whether the form displays a link to edit a response after submitting it.
collectsEmail()BooleanDetermines whether the form collects respondents' email addresses.
createResponse()FormResponseCreates a new response to the form.
deleteAllResponses()FormDeletes all submitted responses from the form's response store.
deleteItem(index)voidDeletes the item at a given index among all the items in the form.
deleteItem(item)voidDeletes the given item.
deleteResponse(responseId)FormDeletes a single response from the form's response store.
getConfirmationMessage()StringGets the form's confirmation message.
getCustomClosedFormMessage()StringGets the custom message that will be displayed if the form is not accepting responses, or an empty string if no custom message has been set.
getDescription()StringGets the form's description.
getDestinationId()StringGets the ID of the form's response destination.
getDestinationType()DestinationTypeGets the type of the form's response destination.
getEditUrl()StringGets the URL that can be used to access the form's edit mode.
getEditors()User[]Gets the list of editors for this Form.
getId()StringGets the ID of the form.
getItemById(id)ItemGets the item with a given ID.
getItems()Item[]Gets an array of all items in the form.
getItems(itemType)Item[]Gets an array of all items of a given type.
getPublishedUrl()StringGets the URL that can be used to respond to the form.
getResponse(responseId)FormResponseGets a single form response based on its response ID.
getResponses()FormResponse[]Gets an array of all of the form's responses.
getResponses(timestamp)FormResponse[]Gets an array of all of the form's responses after a given date and time.
getShuffleQuestions()BooleanDetermines whether the order of the questions on each page of the form is randomized.
getSummaryUrl()StringGets the URL that can be used to view a summary of the form's responses.
getTitle()StringGets the form's title.
hasLimitOneResponsePerUser()BooleanDetermines whether the form allows only one response per respondent.
hasProgressBar()BooleanDetermines whether the form displays a progress bar.
hasRespondAgainLink()BooleanDetermines whether the form displays a link to submit another response after a respondent completes the form.
isAcceptingResponses()BooleanDetermines whether the form is currently accepting responses.
isPublishingSummary()BooleanDetermines whether the form displays a link to view a summary of responses after a respondent completes the form.
isQuiz()BooleanDetermines whether the form is a quiz.
moveItem(from, to)ItemMoves an item at a given index among all the items in the form to another given index.
moveItem(item, toIndex)ItemMoves a given item to an given index among all the items in the form.
removeDestination()FormUnlinks the form from its current response destination.
removeEditor(emailAddress)FormRemoves the given user from the list of editors for the Form.
removeEditor(user)FormRemoves the given user from the list of editors for the Form.
requiresLogin()BooleanDetermines whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.
setAcceptingResponses(enabled)FormSets whether the form is currently accepting responses.
setAllowResponseEdits(enabled)FormSets whether the form displays a link to edit a response after submitting it.
setCollectEmail(collect)FormSets whether the form collects respondents' email addresses.
setConfirmationMessage(message)FormSets the form's confirmation message.
setCustomClosedFormMessage(message)FormSets the message to display if the form is not accepting responses.
setDescription(description)FormSets the form's description.
setDestination(type, id)FormSets the destination where form responses are saved.
setIsQuiz(enabled)FormSets whether the form is a quiz.
setLimitOneResponsePerUser(enabled)FormSets whether the form allows only one response per respondent.
setProgressBar(enabled)FormSets whether the form has a progress bar.
setPublishingSummary(enabled)FormSets whether the form displays a link to view a summary of responses after a respondent submits the form.
setRequireLogin(requireLogin)FormSets whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.
setShowLinkToRespondAgain(enabled)FormSets whether the form displays a link to submit another response after a respondent completes the form.
setShuffleQuestions(shuffle)FormSets whether the order of the questions on each page of the form is randomized.
setTitle(title)FormSets the form's title.
shortenFormUrl(url)StringConverts a long URL for a form to a short URL.
submitGrades(responses)FormSubmits grades for the given FormResponses.

Detailed documentation

addCheckboxGridItem()

Appends a new question item, presented as a grid of columns and rows, that allows the respondent to select multiple choices per row from a sequence of checkboxes.

Return

CheckboxGridItem — the newly created item

Authorization

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

addCheckboxItem()

Appends a new question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.

Return

CheckboxItem — the newly created item

Authorization

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

addDateItem()

Appends a new question item that allows the respondent to indicate a date.

Return

DateItem — the newly created item

Authorization

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

addDateTimeItem()

Appends a new question item that allows the respondent to indicate a date and time.

Return

DateTimeItem — the newly created item

Authorization

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

addDurationItem()

Appends a new question item that allows the respondent to indicate a length of time.

Return

DurationItem — the newly created item

Authorization

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

addEditor(emailAddress)

Adds the given user to the list of editors for the Form. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.

Parameters

NameTypeDescription
emailAddressStringThe email address of the user to add.

Return

Form — This Form, for chaining.

Authorization

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

addEditor(user)

Adds the given user to the list of editors for the Form. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.

Parameters

NameTypeDescription
userUserA representation of the user to add.

Return

Form — This Form, for chaining.

Authorization

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

addEditors(emailAddresses)

Adds the given array of users to the list of editors for the Form. If any of the users were already on the list of viewers, this method promotes them out of the list of viewers.

Parameters

NameTypeDescription
emailAddressesString[]An array of email addresses of the users to add.

Return

Form — This Form, for chaining.

Authorization

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

addGridItem()

Appends a new question item, presented as a grid of columns and rows, that allows the respondent to select one choice per row from a sequence of radio buttons.

Return

GridItem — the newly created item

Authorization

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

addImageItem()

Appends a new layout item that displays an image.

Return

ImageItem — the newly created item

Authorization

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

addListItem()

Appends a new question item that allows the respondent to select one choice from a drop-down list.

Return

ListItem — the newly created item

Authorization

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

addMultipleChoiceItem()

Appends a new question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.

Return

MultipleChoiceItem — the newly created item

Authorization

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

addPageBreakItem()

Appends a new layout item that marks the start of a page.

Return

PageBreakItem — the newly created item

Authorization

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

addParagraphTextItem()

Appends a new question item that allows the respondent to enter a block of text.

Return

ParagraphTextItem — the newly created item

Authorization

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

addScaleItem()

Appends a new question item that allows the respondent to choose one option from a numbered sequence of radio buttons.

Return

ScaleItem — the newly created item

Authorization

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

addSectionHeaderItem()

Appends a new layout item that visually indicates the start of a section.

Return

SectionHeaderItem — the newly created item

Authorization

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

addTextItem()

Appends a new question item that allows the respondent to enter a single line of text.

Return

TextItem — the newly created item

Authorization

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

addTimeItem()

Appends a new question item that allows the respondent to indicate a time of day.

Return

TimeItem — the newly created item

Authorization

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

addVideoItem()

Appends a new layout item that displays a video.

Return

VideoItem — the newly created item

Authorization

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

canEditResponse()

Determines whether the form displays a link to edit a response after submitting it.

Regardless of this setting, the method FormResponse.getEditResponseUrl() allows a script author who has edit access to the form to generate a URL that can be used to edit a response.

Return

Booleantrue if the form displays an "Edit your response" link; false if not

Authorization

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

collectsEmail()

Determines whether the form collects respondents' email addresses.

Return

Booleantrue if the form collects email addresses; false if not

Authorization

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

createResponse()

Creates a new response to the form. To answer a question item, create an ItemResponse from the item, then attach it to this form response by calling FormResponse.withItemResponse(response). To save the assembled response, call FormResponse.submit().

Return

FormResponse — the newly created form response

Authorization

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

deleteAllResponses()

Deletes all submitted responses from the form's response store. This method does not delete copies of responses stored in an external response destination (like a spreadsheet), but does clear the form's summary view.

Return

Form — this Form, for chaining

Authorization

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

deleteItem(index)

Deletes the item at a given index among all the items in the form. Throws a scripting exception if no item exists at the given index.

Parameters

NameTypeDescription
indexIntegerthe 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 following scopes:

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

deleteItem(item)

Deletes the given item. Throws a scripting exception if the item has already been deleted.

Parameters

NameTypeDescription
itemItemthe 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 following scopes:

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

deleteResponse(responseId)

Deletes a single response from the form's response store. This method does not delete copies of responses stored in an external response destination (like a spreadsheet), but does remove the response from the form's summary view. The response ID can be retrieved with FormResponse.getId().

Parameters

NameTypeDescription
responseIdStringthe ID of the form response to delete

Return

Form — this Form, for chaining

Authorization

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

getConfirmationMessage()

Gets the form's confirmation message.

Return

String — the form's confirmation message

Authorization

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

getCustomClosedFormMessage()

Gets the custom message that will be displayed if the form is not accepting responses, or an empty string if no custom message has been set.

Return

String — the custom message that will be displayed if the form is not accepting responses, or an empty string if no custom message has been set

Authorization

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

getDescription()

Gets the form's description.

Return

String — the form's description

Authorization

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

getDestinationId()

Gets the ID of the form's response destination.

Return

String — the ID of the form's response destination

Authorization

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

getDestinationType()

Gets the type of the form's response destination.

Return

DestinationType — the type of the form's response destination

Authorization

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

getEditUrl()

Gets the URL that can be used to access the form's edit mode.

Return

String — the URL to edit the form

Authorization

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

getEditors()

Gets the list of editors for this Form. If the user who executes the script does not have edit access to the Form, this method throws an exception.

Return

User[] — An array of users with edit permission.

Authorization

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

getId()

Gets the ID of the form.

Return

String — the ID of the form

Authorization

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

getItemById(id)

Gets the item with a given ID. Returns null if the ID does not correspond to an item in the form.

Parameters

NameTypeDescription
idIntegerthe item's ID

Return

Item — the item with the given ID, or null if the item does not exist in the form

Authorization

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

getItems()

Gets an array of all items in the form.

Return

Item[] — an array of all items in the form

Authorization

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

getItems(itemType)

Gets an array of all items of a given type.

Parameters

NameTypeDescription
itemTypeItemTypethe 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 following scopes:

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

getPublishedUrl()

Gets the URL that can be used to respond to the form.

Return

String — the URL to respond to the form

Authorization

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

getResponse(responseId)

Gets a single form response based on its response ID. Response IDs can be retrieved from FormResponse.getId().

Parameters

NameTypeDescription
responseIdStringthe ID for the form response

Return

FormResponse — 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 following scopes:

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

getResponses()

Gets an array of all of the form's responses.

Return

FormResponse[] — an array of all of the form's responses

Authorization

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

getResponses(timestamp)

Gets an array of all of the form's responses after a given date and time.

Parameters

NameTypeDescription
timestampDatethe earliest date and time for which form responses should be returned

Return

FormResponse[] — the list of form responses

Authorization

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

getShuffleQuestions()

Determines whether the order of the questions on each page of the form is randomized.

Return

Booleantrue 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 following scopes:

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

getSummaryUrl()

Gets the URL that can be used to view a summary of the form's responses. Unless setPublishingSummary(enabled) is set to true, only users with edit permission to the form will be able to access the 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 following scopes:

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

getTitle()

Gets the form's title.

Return

String — the form's title

Authorization

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

hasLimitOneResponsePerUser()

Determines whether the form allows only one response per respondent. If the value is true, the script cannot submit form responses at all.

Return

Booleantrue 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 following scopes:

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

hasProgressBar()

Determines whether the form displays a progress bar.

Return

Booleantrue if the form displays a progress bar; false if not

Authorization

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

hasRespondAgainLink()

Determines whether the form displays a link to submit another response after a respondent completes the form.

Return

Booleantrue if the form displays a "Submit another response" link; false if not

Authorization

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

isAcceptingResponses()

Determines whether the form is currently accepting responses.

Return

Booleantrue if the form is accepting responses; false if not

Authorization

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

isPublishingSummary()

Determines whether the form displays a link to view a summary of responses after a respondent completes the form.

Return

Booleantrue if the form displays a "See previous responses" link; false if not

Authorization

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

isQuiz()

Determines whether the form is a quiz.

Return

Booleantrue if the form is accepting responses; false if not

Authorization

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

moveItem(from, to)

Moves an item at a given index among all the items in the form to another given index. Throws a scripting exception if the to index is out of bounds.

Parameters

NameTypeDescription
fromIntegerthe current index of the item among all the items in the form
toIntegerthe 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 following scopes:

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

moveItem(item, toIndex)

Moves a given item to an given index among all the items in the form. Throws a scripting exception if the given index is out of bounds.

Parameters

NameTypeDescription
itemItemthe item to move
toIndexIntegerthe 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 following scopes:

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

removeDestination()

Unlinks the form from its current response destination. The unlinked former destination still retains a copy of all previous responses. All forms, including those that do not have a destination set explicitly, save a copy of responses in the form's response store. If the form does not currently have a response destination, this method has no effect.

Return

Form — this Form, for chaining

Authorization

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

removeEditor(emailAddress)

Removes the given user from the list of editors for the Form. This method does not block users from accessing the Form if they belong to a class of users who have general access—for example, if the Form is shared with the user's entire domain.

Parameters

NameTypeDescription
emailAddressStringThe email address of the user to remove.

Return

Form — This Form, for chaining.

Authorization

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

removeEditor(user)

Removes the given user from the list of editors for the Form. This method does not block users from accessing the Form if they belong to a class of users who have general access—for example, if the Form is shared with the user's entire domain.

Parameters

NameTypeDescription
userUserA representation of the user to remove.

Return

Form — This Form, for chaining.

Authorization

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

requiresLogin()

Determines whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.

Return

Booleantrue if the form requires users to log in; false if not


setAcceptingResponses(enabled)

Sets whether the form is currently accepting responses. The default for new forms is true.

Parameters

NameTypeDescription
enabledBooleantrue if the form should accept responses; false if not

Return

Form — this Form, for chaining

Authorization

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

setAllowResponseEdits(enabled)

Sets whether the form displays a link to edit a response after submitting it. The default for new forms is false.

Regardless of this setting, the method FormResponse.getEditResponseUrl() allows a script author who has edit permission to the form to generate a URL that can be used to edit a response.

Parameters

NameTypeDescription
enabledBooleantrue if the form should display an "Edit your response" link; false if not

Return

Form — this Form, for chaining

Authorization

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

setCollectEmail(collect)

Sets whether the form collects respondents' email addresses. The default for new forms is false.

Parameters

NameTypeDescription
collectBooleantrue if the form should collect email addresses; false if not

Return

Form — this Form, for chaining

Authorization

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

setConfirmationMessage(message)

Sets the form's confirmation message.

Parameters

NameTypeDescription
messageStringthe form's new confirmation message

Return

Form — this Form, for chaining

Authorization

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

setCustomClosedFormMessage(message)

Sets the message to display if the form is not accepting responses. If no message is set, the form will use a default message.

Parameters

NameTypeDescription
messageStringthe message to display if the form is not accepting responses

Return

Form — this Form, for chaining

Authorization

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

setDescription(description)

Sets the form's description.

Parameters

NameTypeDescription
descriptionStringthe form's new description

Return

Form — this Form, for chaining

Authorization

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

setDestination(type, id)

Sets the destination where form responses are saved. All forms, including those that do not have a destination set explicitly, save a copy of responses in the form's response store.

Parameters

NameTypeDescription
typeDestinationTypethe type of the form's response destination
idStringthe ID of the form's response destination

Return

Form — this Form, 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 following scopes:

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

setIsQuiz(enabled)

Sets whether the form is a quiz. The default for new forms is false.

Graded questions are only allowed in Quizzes, so setting this to false will cause all grading options to be removed from all questions.

Quiz settings are only available in the new Forms UI; making a form a Quiz will opt the form into using the new UI.

Parameters

NameTypeDescription
enabledBooleantrue if quiz features should be enabled for the form; false if not

Return

Form — this Form, for chaining

Authorization

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

setLimitOneResponsePerUser(enabled)

Sets whether the form allows only one response per respondent. The default for new forms is false. If the value is set to true, the script cannot submit form responses at all.

Parameters

NameTypeDescription
enabledBooleantrue if the form should allow only one response per respondent; false if not

Return

Form — this Form, for chaining

Authorization

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

setProgressBar(enabled)

Sets whether the form has a progress bar. The default for new forms is false.

Parameters

NameTypeDescription
enabledBooleantrue if the form should display a progress bar; false if not

Return

Form — this Form, for chaining

Authorization

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

setPublishingSummary(enabled)

Sets whether the form displays a link to view a summary of responses after a respondent submits the form. The default for new forms is false.

Parameters

NameTypeDescription
enabledBooleantrue if the form should display a "See previous responses" link; false if not

Return

Form — this Form, for chaining

Authorization

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

setRequireLogin(requireLogin)

Sets whether the form requires respondents to log in to an account in the same domain or a subdomain before responding. The default for new forms is false unless a domain administrator changes the default.

This feature is available only for forms created by G Suite users. Users of other types of Google accounts cannot be required to log in.

Parameters

NameTypeDescription
requireLoginBooleantrue if the form requires users to log in; false if not

Return

Form — the current form (for chaining)

Authorization

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

setShowLinkToRespondAgain(enabled)

Sets whether the form displays a link to submit another response after a respondent completes the form. The default for new forms is true.

Parameters

NameTypeDescription
enabledBooleantrue if the form should display a "Submit another response" link; false if not

Return

Form — this Form, for chaining

Authorization

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

setShuffleQuestions(shuffle)

Sets whether the order of the questions on each page of the form is randomized.

Parameters

NameTypeDescription
shuffleBooleantrue if the order of the questions on each page of the form should be randomized; false if not

Return

Form — this Form, for chaining

Authorization

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

setTitle(title)

Sets the form's title.

Parameters

NameTypeDescription
titleStringthe form's new title

Return

Form — this Form, for chaining

Authorization

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

shortenFormUrl(url)

Converts a long URL for a form to a short URL. Throws an exception if the long URL does not belong to Google Forms.

Parameters

NameTypeDescription
urlString

Return

String — a URL in the form http://goo.gl/forms/1234

Authorization

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

submitGrades(responses)

Submits grades for the given FormResponses.

Parameters

NameTypeDescription
responsesFormResponse[]

Return

Form — this Form, for chaining

Authorization

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

Send feedback about...

Apps Script
Apps Script
Need help? Visit our support page.