Interface Item

  • Item is a generic form item with common properties like title and help text, accessible or created from a Form.

  • To work with type-specific properties, check the item's type usinggetType() and cast it to the appropriate class using methods likeasCheckboxItem().

  • The documentation provides a list of methods to cast a generic Item to various specific item types, such asasCheckboxGridItem(),asDateItem(), andasTextItem().

  • Methods likeduplicate(),getHelpText(),getId(),getIndex(),getTitle(),getType(),setHelpText(), andsetTitle() are available for operating on the Item object.

  • Scripts using these methods often require specific authorization scopes related to Google Forms.

Item

A generic form item that contains properties common to all items, such as title and help text.Items can be accessed or created from aForm.

To operate on type-specific properties, usegetType() to check the item'sItemType, then cast the item to theappropriate class using a method likeasCheckboxItem().

// Create a new form and add a text item.constform=FormApp.create('Form Name');form.addTextItem();// Access the text item as a generic item.constitems=form.getItems();constitem=items[0];// Cast the generic item to the text-item class.if(item.getType()==='TEXT'){consttextItem=item.asTextItem();textItem.setRequired(false);}

Implementing classes

NameBrief description

Methods

MethodReturn typeBrief description
asCheckboxGridItem()CheckboxGridItemReturns the item as a checkbox grid item.
asCheckboxItem()CheckboxItemReturns the item as a checkbox item.
asDateItem()DateItemReturns the item as a date item.
asDateTimeItem()DateTimeItemReturns the item as a date-time item.
asDurationItem()DurationItemReturns the item as a duration item.
asGridItem()GridItemReturns the item as a grid item.
asImageItem()ImageItemReturns the item as an image item.
asListItem()ListItemReturns the item as a list item.
asMultipleChoiceItem()MultipleChoiceItemReturns the item as a multiple-choice item.
asPageBreakItem()PageBreakItemReturns the item as a page-break item.
asParagraphTextItem()ParagraphTextItemReturns the item as a paragraph-text item.
asRatingItem()RatingItemReturns the item as a rating item.
asScaleItem()ScaleItemReturns the item as a scale item.
asSectionHeaderItem()SectionHeaderItemReturns the item as a section-header item.
asTextItem()TextItemReturns the item as a text item.
asTimeItem()TimeItemReturns the item as a time item.
asVideoItem()VideoItemReturns the item as a video item.
duplicate()ItemCreates a copy of this item and appends it to the end of the form.
getHelpText()StringGets the item's help text (sometimes called description text for layout items likeImageItems,PageBreakItems, andSectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getTitle()StringGets the item's title (sometimes called header text, in the case of aSectionHeaderItem).
getType()ItemTypeGets the item's type, represented as anItemType.
setHelpText(text)ItemSets the item's help text (sometimes called description text for layout items likeImageItems,PageBreakItems, andSectionHeaderItems).
setTitle(title)ItemSets the item's title (sometimes called header text, in the case of aSectionHeaderItem).

Detailed documentation

asCheckboxGridItem()

Returns the item as a checkbox grid item. Throws a scripting exception if theItemType was not alreadyCHECKBOX_GRID.

Return

CheckboxGridItem — the checkbox grid item

Throws

Error — if the item is not a checkbox grid item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asCheckboxItem()

Returns the item as a checkbox item. Throws a scripting exception if theItemType was not alreadyCHECKBOX.

Return

CheckboxItem — the checkbox item

Throws

Error — if the item is not a checkbox item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asDateItem()

Returns the item as a date item. Throws a scripting exception if theItemType was not alreadyDATE.

Return

DateItem — the date item

Throws

Error — if the item is not a date item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asDateTimeItem()

Returns the item as a date-time item. Throws a scripting exception if theItemType was not alreadyDATETIME.

Return

DateTimeItem — the date-time item

Throws

Error — if the item is not a date-time item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asDurationItem()

Returns the item as a duration item. Throws a scripting exception if theItemType was not alreadyDURATION.

Return

DurationItem — the duration item

Throws

Error — if the item is not a duration item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asGridItem()

Returns the item as a grid item. Throws a scripting exception if theItemType was not alreadyGRID.

Return

GridItem — the grid item

Throws

Error — if the item is not a grid item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asImageItem()

Returns the item as an image item. Throws a scripting exception if theItemType was not alreadyIMAGE.

Return

ImageItem — the image item

Throws

Error — if the item is not an image item


asListItem()

Returns the item as a list item. Throws a scripting exception if theItemType was not alreadyLIST.

Return

ListItem — the list item

Throws

Error — if the item is not a list item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asMultipleChoiceItem()

Returns the item as a multiple-choice item. Throws a scripting exception if theItemType was not alreadyMULTIPLE_CHOICE.

Return

MultipleChoiceItem — the multiple-choice item

Throws

Error — if the item is not a multiple choice item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asPageBreakItem()

Returns the item as a page-break item. Throws a scripting exception if theItemType was not alreadyPAGE_BREAK.

Return

PageBreakItem — the page-break item

Throws

Error — if the item is not a page break item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asParagraphTextItem()

Returns the item as a paragraph-text item. Throws a scripting exception if theItemType was not alreadyPARAGRAPH_TEXT.

Return

ParagraphTextItem — the paragraph-text item

Throws

Error — if the item is not a paragraph text item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asRatingItem()

Returns the item as a rating item. Throws a ScriptingException if theItemType was not alreadyRATING.

// Opens the Forms file by its URL. If you created your script from within a// Google Forms file, you can use FormApp.getActiveForm() instead.// TODO(developer): Replace the URL with your own.constform=FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');// Fetch any item which is of type rating.constitem=form.getItems(FormApp.ItemType.RATING)[0];// Convert the item to a rating item.constratingItem=item.asRatingItem();

Return

RatingItem — The rating item.

Throws

Error — if the item is not a rating item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asScaleItem()

Returns the item as a scale item. Throws a scripting exception if theItemType was not alreadySCALE.

Return

ScaleItem — the scale item

Throws

Error — if the item is not a scale item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asSectionHeaderItem()

Returns the item as a section-header item. Throws a scripting exception if theItemType was not alreadySECTION_HEADER.

Return

SectionHeaderItem — the section-header item

Throws

Error — if the item is not a section header item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asTextItem()

Returns the item as a text item. Throws a scripting exception if theItemType was not alreadyTEXT.

Return

TextItem — the text item

Throws

Error — if the item is not a text item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asTimeItem()

Returns the item as a time item. Throws a scripting exception if theItemType was not alreadyTIME.

Return

TimeItem — the time item

Throws

Error — if the item is not a time item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

asVideoItem()

Returns the item as a video item. Throws a scripting exception if theItemType was not alreadyVIDEO.

Return

VideoItem — the video item

Throws

Error — if the item is not a video item


duplicate()

Creates a copy of this item and appends it to the end of the form.

Return

Item — a duplicate of thisItem, for chaining

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

getHelpText()

Gets the item's help text (sometimes called description text for layout items likeImageItems,PageBreakItems, andSectionHeaderItems).

Return

String — the item's help text or description text

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

getId()

Gets the item's unique identifier.

Return

Integer — the item's ID

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

getIndex()

Gets the index of the item among all the items in the form.

Return

Integer — the index of the item

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

getTitle()

Gets the item's title (sometimes called header text, in the case of aSectionHeaderItem).

Return

String — the item's title or header text

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

getType()

Gets the item's type, represented as anItemType.

Return

ItemType — the item's type

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

setHelpText(text)

Sets the item's help text (sometimes called description text for layout items likeImageItems,PageBreakItems, andSectionHeaderItems).

Parameters

NameTypeDescription
textStringthe new help text

Return

Item — thisItem, for chaining

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

setTitle(title)

Sets the item's title (sometimes called header text, in the case of aSectionHeaderItem).

Parameters

NameTypeDescription
titleStringthe new title or header text

Return

Item — thisItem, for chaining

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

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

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.