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

Method Return type Brief description
CheckboxGridItem 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.
CheckboxItem Appends a new question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.
DateItem Appends a new question item that allows the respondent to indicate a date.
DateTimeItem Appends a new question item that allows the respondent to indicate a date and time.
DurationItem Appends a new question item that allows the respondent to indicate a length of time.
Form Adds the given user to the list of editors for the Form .
Form Adds the given user to the list of editors for the Form .
Form Adds the given array of users to the list of editors for the Form .
GridItem 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.
ImageItem Appends a new layout item that displays an image.
ListItem Appends a new question item that allows the respondent to select one choice from a dropdown list.
MultipleChoiceItem Adds a new question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.
PageBreakItem Adds a new layout item that marks the start of a page.
ParagraphTextItem Adds a new question item that allows the respondent to enter a block of text.
ScaleItem Appends a new question item that allows the respondent to choose one option from a numbered sequence of radio buttons.
SectionHeaderItem Appends a new layout item that visually indicates the start of a section.
TextItem Appends a new question item that allows the respondent to enter a single line of text.
TimeItem Appends a new question item that allows the respondent to indicate a time of day.
VideoItem Appends a new layout item that displays a video.
Boolean Determines whether the form displays a link to edit a response after submitting it.
Boolean Determines whether the form collects respondents' email addresses.
FormResponse Creates a new response to the form.
Form Deletes all submitted responses from the form's response store.
void Deletes the item at a given index among all the items in the form.
void Deletes the given item.
Form Deletes a single response from the form's response store.
String Gets the form's confirmation message.
String Gets the custom message that is displayed if the form is not accepting responses, or an empty string if no custom message is set.
String Gets the form's description.
String Gets the ID of the form's response destination.
DestinationType Gets the type of the form's response destination.
String Gets the URL that can be used to access the form's edit mode.
User[] Gets the list of editors for this Form .
String Gets the ID of the form.
Item Gets the item with a given ID.
Item[] Gets an array of all items in the form.
Item[] Gets an array of all items of a given type.
String Gets the URL that can be used to respond to the form.
FormResponse Gets a single form response based on its response ID.
FormResponse[] Gets an array of all of the form's responses.
FormResponse[] Gets an array of all of the form's responses after a given date and time.
Boolean Determines whether the order of the questions on each page of the form is randomized.
String Gets the URL that can be used to view a summary of the form's responses.
String Gets the form's title.
Boolean Determines whether the form allows only one response per respondent.
Boolean Determines whether the form displays a progress bar.
Boolean Determines whether the form displays a link to submit another response after a respondent completes the form.
Boolean Determines whether the form is currently accepting responses.
Boolean Determines whether the form displays a link to view a summary of responses after a respondent completes the form.
Boolean Determines whether the form is a quiz.
Item Moves an item at a given index among all the items in the form to another given index.
Item Moves a given item to a given index among all the items in the form.
Form Unlinks the form from its current response destination.
Form Removes the given user from the list of editors for the Form .
Form Removes the given user from the list of editors for the Form .
Boolean Determines whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.
Form Sets whether the form is currently accepting responses.
Form Sets whether the form displays a link to edit a response after submitting it.
Form Sets whether the form collects respondents' email addresses.
Form Sets the form's confirmation message.
Form Sets the message to display if the form is not accepting responses.
Form Sets the form's description.
Form Sets the destination where form responses are saved.
Form Sets whether the form is a quiz.
Form Sets whether the form allows only one response per respondent.
Form Sets whether the form has a progress bar.
Form Sets whether the form displays a link to view a summary of responses after a respondent submits the form.
Form Sets whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.
Form Sets whether the form displays a link to submit another response after a respondent completes the form.
Form Sets whether the order of the questions on each page of the form is randomized.
Form Sets the form's title.
String Converts a long URL for a form to a short URL.
Form Submits 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 checkbox 
  
 grid 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 form 
 . 
 addCheckboxGridItem 
 (); 
 // 
  
 Sets 
  
 the 
  
 title 
  
 'Where did you celebrate New Year' 
 s 
 ? 
 ' 
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 checkbox 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 date 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 question 
  
 with 
  
 date 
  
 and 
  
 time 
  
 inputs 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 question 
  
 with 
  
 a 
  
 duration 
  
 input 
 . 
 const 
  
 item 
  
 = 
  
 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

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

Name Type Description
emailAddress
String The 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

Name Type Description
user
User A 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

Name Type Description
emailAddresses
String[] 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 multiple 
  
 choice 
  
 grid 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 an 
  
 image 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 form 
 . 
 addImageItem 
 (); 
 // 
  
 Gets 
  
 the 
  
 Google 
  
 icon 
  
 to 
  
 use 
  
 as 
  
 the 
  
 image 
 . 
 const 
  
 img 
  
 = 
  
 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

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 dropdown 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 dropdown 
  
 list 
  
 to 
  
 the 
  
 form 
 . 
 const 
  
 item 
  
 = 
  
 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

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()

Adds a new question item that allows the respondent to select one choice from a list of radio buttons 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 multiple 
  
 choice 
  
 item 
  
 to 
  
 the 
  
 form 
 . 
 const 
  
 item 
  
 = 
  
 form 
 . 
 addMultipleChoiceItem 
 (); 
 // 
  
 Sets 
  
 the 
  
 title 
 . 
 item 
 . 
 setTitle 
 ( 
 'What is your favorite ice cream flavor?' 
 ); 
 // 
  
 Creates 
  
 some 
  
 choice 
  
 items 
 . 
 const 
  
 vanilla 
  
 = 
  
 item 
 . 
 createChoice 
 ( 
 'vanilla' 
 ); 
 const 
  
 chocolate 
  
 = 
  
 item 
 . 
 createChoice 
 ( 
 'chocolate' 
 ); 
 const 
  
 strawberry 
  
 = 
  
 item 
 . 
 createChoice 
 ( 
 'strawberry' 
 ); 
 // 
  
 Sets 
  
 the 
  
 choices 
 . 
 item 
 . 
 setChoices 
 ([ 
 vanilla 
 , 
  
 chocolate 
 , 
  
 strawberry 
 ]); 

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()

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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 page 
  
 break 
  
 items 
  
 to 
  
 create 
  
 a 
  
 second 
  
 and 
  
 third 
  
 page 
  
 for 
  
 the 
  
 form 
 . 
 const 
  
 pageTwo 
  
 = 
  
 form 
 . 
 addPageBreakItem 
 (); 
 const 
  
 pageThree 
  
 = 
  
 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

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()

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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 the 
  
 paragraph 
  
 text 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 form 
 . 
 addParagraphTextItem 
 (); 
 // 
  
 Sets 
  
 the 
  
 title 
  
 to 
  
 'What is your address?' 
 item 
 . 
 setTitle 
 ( 
 'What is your address?' 
 ); 

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 the 
  
 scale 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

  
 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 the 
  
 section 
  
 heading 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 single 
 - 
 line 
  
 text 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 form 
 . 
 addTextItem 
 (); 
 // 
  
 Sets 
  
 the 
  
 title 
  
 to 
  
 'What is your name?' 
 item 
 . 
 setTitle 
 ( 
 'What is your name?' 
 ); 

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 question 
  
 with 
  
 a 
  
 time 
  
 input 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Adds 
  
 a 
  
 video 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 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

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 ) 
 . 
 const 
  
 edit 
  
 = 
  
 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 following scopes :

  • https://www.googleapis.com/auth/forms.currentonly
  • https://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 
 . 
 const 
  
 form 
  
 = 
  
 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. 
 const 
  
 bool 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 all 
  
 the 
  
 items 
  
 from 
  
 the 
  
 form 
 . 
 const 
  
 items 
  
 = 
  
 form 
 . 
 getItems 
 (); 
 // 
  
 Finds 
  
 the 
  
 index 
  
 of 
  
 a 
  
 paragraph 
  
 text 
  
 item 
  
 and 
  
 deletes 
  
 it 
  
 by 
  
 the 
  
 item 
 's index. 
 const 
  
 index 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 all 
  
 of 
  
 the 
  
 items 
  
 from 
  
 the 
  
 form 
 . 
 const 
  
 items 
  
 = 
  
 form 
 . 
 getItems 
 (); 
 // 
  
 Finds 
  
 a 
  
 paragraph 
  
 text 
  
 item 
  
 and 
  
 deletes 
  
 it 
 . 
 const 
  
 item 
  
 = 
  
 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 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

Name Type Description
responseId
String The 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 message 
  
 = 
  
 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 following scopes :

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

getCustomClosedFormMessage()

Gets the custom message that is displayed if the form is not accepting responses, or an empty string 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 message 
  
 = 
  
 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 following scopes :

  • https://www.googleapis.com/auth/forms.currentonly
  • https://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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 description 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Creates 
  
 a 
  
 spreadsheet 
  
 to 
  
 use 
  
 as 
  
 the 
  
 response 
  
 destination 
 . 
 const 
  
 ss 
  
 = 
  
 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. 
 const 
  
 destinationId 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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. 
 const 
  
 destinationType 
  
 = 
  
 form 
 . 
 getDestinationType 
 () 
 . 
 name 
 (); 
 console 
 . 
 log 
 ( 
 destinationType 
 ); 

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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. 
 const 
  
 url 
  
 = 
  
 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 following scopes :

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

getEditors()

Gets the list of editors for this Form .

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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 the 
  
 ID 
  
 of 
  
 the 
  
 form 
  
 and 
  
 logs 
  
 it 
  
 to 
  
 the 
  
 console 
 . 
 const 
  
 id 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 the 
  
 ID 
  
 of 
  
 the 
  
 first 
  
 item 
  
 on 
  
 the 
  
 form 
 . 
 const 
  
 itemId 
  
 = 
  
 form 
 . 
 getItems 
 ()[ 
 0 
 ] 
 . 
 getId 
 (); 
 // 
  
 Gets 
  
 the 
  
 item 
  
 from 
  
 the 
  
 ID 
 . 
 const 
  
 item 
  
 = 
  
 form 
 . 
 getItemById 
 ( 
 itemId 
 ); 
 // 
  
 Gets 
  
 the 
  
 name 
  
 of 
  
 the 
  
 item 
  
 type 
  
 and 
  
 logs 
  
 it 
  
 to 
  
 the 
  
 console 
 . 
 const 
  
 type 
  
 = 
  
 item 
 . 
 getType 
 () 
 . 
 name 
 (); 
 console 
 . 
 log 
 ( 
 type 
 ); 

Parameters

Name Type Description
id
Integer The 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 the 
  
 list 
  
 of 
  
 items 
  
 in 
  
 the 
  
 form 
 . 
 const 
  
 items 
  
 = 
  
 form 
 . 
 getItems 
 (); 
 // 
  
 Gets 
  
 the 
  
 type 
  
 for 
  
 each 
  
 item 
  
 and 
  
 logs 
  
 them 
  
 to 
  
 the 
  
 console 
 . 
 const 
  
 types 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 a 
  
 list 
  
 of 
  
 all 
  
 checkbox 
  
 items 
  
 on 
  
 the 
  
 form 
 . 
 const 
  
 items 
  
 = 
  
 form 
 . 
 getItems 
 ( 
 FormApp 
 . 
 ItemType 
 . 
 CHECKBOX 
 ); 
 // 
  
 Gets 
  
 the 
  
 title 
  
 of 
  
 each 
  
 checkbox 
  
 item 
  
 and 
  
 logs 
  
 them 
  
 to 
  
 the 
  
 console 
 . 
 const 
  
 checkboxItemsTitle 
  
 = 
  
 items 
 . 
 map 
 (( 
 item 
 ) 
  
 = 
>  
 item 
 . 
 asCheckboxItem 
 () 
 . 
 getTitle 
 ()); 
 console 
 . 
 log 
 ( 
 checkboxItemsTitle 
 ); 

Parameters

Name Type Description
itemType
ItemType 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 the 
  
 URL 
  
 to 
  
 respond 
  
 to 
  
 the 
  
 form 
  
 and 
  
 logs 
  
 it 
  
 to 
  
 the 
  
 console 
 . 
 const 
  
 url 
  
 = 
  
 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 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

Name Type Description
responseId
String The 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

Name Type Description
timestamp
Date The 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

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 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 the users with edit permission to the form 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 
 . 
 const 
  
 form 
  
 = 
  
 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. 
 const 
  
 url 
  
 = 
  
 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 following scopes :

  • https://www.googleapis.com/auth/forms.currentonly
  • https://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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 title 
  
 = 
  
 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 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

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

  • https://www.googleapis.com/auth/forms.currentonly
  • https://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 
 . 
 const 
  
 form 
  
 = 
  
 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 following scopes :

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

Determines whether the form displays a link to submit another response after a respondent completes 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 
 . 
 const 
  
 form 
  
 = 
  
 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 following scopes :

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

isAcceptingResponses()

Determines whether the form is currently accepting responses.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 accepting 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 publishingLink 
  
 = 
  
 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 following scopes :

  • https://www.googleapis.com/auth/forms.currentonly
  • https://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 
 . 
 const 
  
 form 
  
 = 
  
 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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 following scopes :

  • https://www.googleapis.com/auth/forms.currentonly
  • https://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 scripting exception 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 
 . 
 const 
  
 form 
  
 = 
  
 FormApp 
 . 
 openByUrl 
 ( 
 'https://docs.google.com/forms/d/abc123456/edit' 
 ); 
 // 
  
 Gets 
  
 the 
  
 first 
  
 item 
 . 
 const 
  
 item 
  
 = 
  
 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.
toIndex
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 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 ss 
  
 = 
  
 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 — 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 doesn't 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, or if the Form is in a shared drive that the user can access.

For Drive files, this also removes the user from the list of viewers.

Parameters

Name Type Description
emailAddress
String The 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 doesn't 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, or if the Form is in a shared drive that the user can access.

For Drive files, this also removes the user from the list of viewers.

Parameters

Name Type Description
user
User A 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 login 
  
 = 
  
 form 
 . 
 requiresLogin 
 (); 
 console 
 . 
 log 
 ( 
 login 
 ); 

Return

Boolean true if the form requires users to log in; false if it doesn't.


setAcceptingResponses(enabled)

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

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 — 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 — 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 .

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 collect 
  
 = 
  
 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 — 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.

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 message 
  
 = 
  
 form 
 . 
 getConfirmationMessage 
 (); 
 console 
 . 
 log 
 ( 
 message 
 ); 

Parameters

Name Type Description
message
String The 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 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 
 . 
 const 
  
 form 
  
 = 
  
 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 
 . 
 const 
  
 message 
  
 = 
  
 form 
 . 
 getCustomClosedFormMessage 
 (); 
 console 
 . 
 log 
 ( 
 message 
 ); 

Parameters

Name Type Description
message
String The 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

Name Type Description
description
String The 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

Name Type Description
type
DestinationType The type of the form's response destination.
id
String The 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 causes all grading options to be removed from all questions.

Quiz settings are only available in the new Forms UI; making a form a Quiz opts the form into 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 
 . 
 const 
  
 form 
  
 = 
  
 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 — 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

Name Type Description
enabled
Boolean true 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 .

 // 
  
 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 
 . 
 const 
  
 form 
  
 = 
  
 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 — 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

Name Type Description
enabled
Boolean true 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 Google Workspace users. Users of other types 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 
 . 
 const 
  
 form 
  
 = 
  
 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
requireLogin
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 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

Name Type Description
enabled
Boolean true 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

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 — 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

Name Type Description
title
String The 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

Name Type Description
url
String The URL to shorten.

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.

If your code includes an onFormSubmit trigger, calling submitGrades() triggers the onFormSubmit condition and causes an infinite loop. To prevent the infinite loop, add code that checks whether grades already exist before calling submitGrades() .

Parameters

Name Type Description
responses
FormResponse[] An array of all of the form's 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