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 a `https://developers.google.com/apps-script/reference/forms/form`.

To operate on type-specific properties, use `https://developers.google.com/apps-script/reference/forms/item#getType()` to check the item's `https://developers.google.com/apps-script/reference/forms/item-type`, then cast the item to the
appropriate class using a method like `https://developers.google.com/apps-script/reference/forms/item#asCheckboxItem()`.

```javascript
// Create a new form and add a text item.
const form = FormApp.create('Form Name');
form.addTextItem();

// Access the text item as a generic item.
const items = form.getItems();
const item = items[0];

// Cast the generic item to the text-item class.
if (item.getType() === 'TEXT') {
  const textItem = item.asTextItem();
  textItem.setRequired(false);
}
```

### Implementing classes

| Name | Brief description |
|---|---|

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/forms/item#asCheckboxGridItem()` | `https://developers.google.com/apps-script/reference/forms/checkbox-grid-item` | Returns the item as a checkbox grid item. |
| `https://developers.google.com/apps-script/reference/forms/item#asCheckboxItem()` | `https://developers.google.com/apps-script/reference/forms/checkbox-item` | Returns the item as a checkbox item. |
| `https://developers.google.com/apps-script/reference/forms/item#asDateItem()` | `https://developers.google.com/apps-script/reference/forms/date-item` | Returns the item as a date item. |
| `https://developers.google.com/apps-script/reference/forms/item#asDateTimeItem()` | `https://developers.google.com/apps-script/reference/forms/date-time-item` | Returns the item as a date-time item. |
| `https://developers.google.com/apps-script/reference/forms/item#asDurationItem()` | `https://developers.google.com/apps-script/reference/forms/duration-item` | Returns the item as a duration item. |
| `https://developers.google.com/apps-script/reference/forms/item#asGridItem()` | `https://developers.google.com/apps-script/reference/forms/grid-item` | Returns the item as a grid item. |
| `https://developers.google.com/apps-script/reference/forms/item#asImageItem()` | `https://developers.google.com/apps-script/reference/forms/image-item` | Returns the item as an image item. |
| `https://developers.google.com/apps-script/reference/forms/item#asListItem()` | `https://developers.google.com/apps-script/reference/forms/list-item` | Returns the item as a list item. |
| `https://developers.google.com/apps-script/reference/forms/item#asMultipleChoiceItem()` | `https://developers.google.com/apps-script/reference/forms/multiple-choice-item` | Returns the item as a multiple-choice item. |
| `https://developers.google.com/apps-script/reference/forms/item#asPageBreakItem()` | `https://developers.google.com/apps-script/reference/forms/page-break-item` | Returns the item as a page-break item. |
| `https://developers.google.com/apps-script/reference/forms/item#asParagraphTextItem()` | `https://developers.google.com/apps-script/reference/forms/paragraph-text-item` | Returns the item as a paragraph-text item. |
| `https://developers.google.com/apps-script/reference/forms/item#asRatingItem()` | `https://developers.google.com/apps-script/reference/forms/rating-item` | Returns the item as a rating item. |
| `https://developers.google.com/apps-script/reference/forms/item#asScaleItem()` | `https://developers.google.com/apps-script/reference/forms/scale-item` | Returns the item as a scale item. |
| `https://developers.google.com/apps-script/reference/forms/item#asSectionHeaderItem()` | `https://developers.google.com/apps-script/reference/forms/section-header-item` | Returns the item as a section-header item. |
| `https://developers.google.com/apps-script/reference/forms/item#asTextItem()` | `https://developers.google.com/apps-script/reference/forms/text-item` | Returns the item as a text item. |
| `https://developers.google.com/apps-script/reference/forms/item#asTimeItem()` | `https://developers.google.com/apps-script/reference/forms/time-item` | Returns the item as a time item. |
| `https://developers.google.com/apps-script/reference/forms/item#asVideoItem()` | `https://developers.google.com/apps-script/reference/forms/video-item` | Returns the item as a video item. |
| `https://developers.google.com/apps-script/reference/forms/item#duplicate()` | `https://developers.google.com/apps-script/reference/forms/item#` | Creates a copy of this item and appends it to the end of the form. |
| `https://developers.google.com/apps-script/reference/forms/item#getHelpText()` | `String` | Gets the item's help text (sometimes called description text for layout items like `https://developers.google.com/apps-script/reference/forms/image-item`, `https://developers.google.com/apps-script/reference/forms/page-break-item`, and `https://developers.google.com/apps-script/reference/forms/section-header-item`). |
| `https://developers.google.com/apps-script/reference/forms/item#getId()` | `Integer` | Gets the item's unique identifier. |
| `https://developers.google.com/apps-script/reference/forms/item#getIndex()` | `Integer` | Gets the index of the item among all the items in the form. |
| `https://developers.google.com/apps-script/reference/forms/item#getTitle()` | `String` | Gets the item's title (sometimes called header text, in the case of a `https://developers.google.com/apps-script/reference/forms/section-header-item`). |
| `https://developers.google.com/apps-script/reference/forms/item#getType()` | `https://developers.google.com/apps-script/reference/forms/item-type` | Gets the item's type, represented as an `https://developers.google.com/apps-script/reference/forms/item-type`. |
| `https://developers.google.com/apps-script/reference/forms/item#setHelpText(String)` | `https://developers.google.com/apps-script/reference/forms/item#` | Sets the item's help text (sometimes called description text for layout items like `https://developers.google.com/apps-script/reference/forms/image-item`, `https://developers.google.com/apps-script/reference/forms/page-break-item`, and `https://developers.google.com/apps-script/reference/forms/section-header-item`). |
| `https://developers.google.com/apps-script/reference/forms/item#setTitle(String)` | `https://developers.google.com/apps-script/reference/forms/item#` | Sets the item's title (sometimes called header text, in the case of a `https://developers.google.com/apps-script/reference/forms/section-header-item`). |

## Detailed documentation

### `asCheckboxGridItem()`

Returns the item as a checkbox grid item. Throws a scripting exception if the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `CHECKBOX_GRID`.

#### Return


`https://developers.google.com/apps-script/reference/forms/checkbox-grid-item` --- the checkbox grid item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a checkbox grid item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `CHECKBOX`.

#### Return


`https://developers.google.com/apps-script/reference/forms/checkbox-item` --- the checkbox item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a checkbox item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `DATE`.

#### Return


`https://developers.google.com/apps-script/reference/forms/date-item` --- the date item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a date item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `DATETIME`.

#### Return


`https://developers.google.com/apps-script/reference/forms/date-time-item` --- the date-time item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a date-time item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `DURATION`.

#### Return


`https://developers.google.com/apps-script/reference/forms/duration-item` --- the duration item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a duration item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `GRID`.

#### Return


`https://developers.google.com/apps-script/reference/forms/grid-item` --- the grid item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a grid item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `IMAGE`.

#### Return


`https://developers.google.com/apps-script/reference/forms/image-item` --- the image item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not an image item

*** ** * ** ***

### `asListItem()`

Returns the item as a list item. Throws a scripting exception if the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `LIST`.

#### Return


`https://developers.google.com/apps-script/reference/forms/list-item` --- the list item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a list item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `MULTIPLE_CHOICE`.

#### Return


`https://developers.google.com/apps-script/reference/forms/multiple-choice-item` --- the multiple-choice item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a multiple choice item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `PAGE_BREAK`.

#### Return


`https://developers.google.com/apps-script/reference/forms/page-break-item` --- the page-break item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a page break item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `PARAGRAPH_TEXT`.

#### Return


`https://developers.google.com/apps-script/reference/forms/paragraph-text-item` --- the paragraph-text item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a paragraph text item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `RATING`.

```javascript
// 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');

// Fetch any item which is of type rating.
const item = form.getItems(FormApp.ItemType.RATING)[0];

// Convert the item to a rating item.
const ratingItem = item.asRatingItem();
```

#### Return


`https://developers.google.com/apps-script/reference/forms/rating-item` --- The rating item.

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a rating item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `SCALE`.

#### Return


`https://developers.google.com/apps-script/reference/forms/scale-item` --- the scale item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a scale item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `SECTION_HEADER`.

#### Return


`https://developers.google.com/apps-script/reference/forms/section-header-item` --- the section-header item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a section header item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `TEXT`.

#### Return


`https://developers.google.com/apps-script/reference/forms/text-item` --- the text item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a text item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `TIME`.

#### Return


`https://developers.google.com/apps-script/reference/forms/time-item` --- the time item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the item is not a time item

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 the `https://developers.google.com/apps-script/reference/forms/item-type` was not already `VIDEO`.

#### Return


`https://developers.google.com/apps-script/reference/forms/video-item` --- the video item

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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


`https://developers.google.com/apps-script/reference/forms/item#` --- a duplicate of this `https://developers.google.com/apps-script/reference/forms/item#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 like `https://developers.google.com/apps-script/reference/forms/image-item`, `https://developers.google.com/apps-script/reference/forms/page-break-item`, and `https://developers.google.com/apps-script/reference/forms/section-header-item`).

#### Return


`String` --- the item's help text or description text

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 a `https://developers.google.com/apps-script/reference/forms/section-header-item`).

#### Return


`String` --- the item's title or header text

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/forms.currentonly`
- `https://www.googleapis.com/auth/forms`

*** ** * ** ***

### `getType()`

Gets the item's type, represented as an `https://developers.google.com/apps-script/reference/forms/item-type`.

#### Return


`https://developers.google.com/apps-script/reference/forms/item-type` --- the item's type

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 like `https://developers.google.com/apps-script/reference/forms/image-item`, `https://developers.google.com/apps-script/reference/forms/page-break-item`, and `https://developers.google.com/apps-script/reference/forms/section-header-item`).

#### Parameters

| Name | Type | Description |
|---|---|---|
| `text` | `String` | the new help text |

#### Return


`https://developers.google.com/apps-script/reference/forms/item#` --- this `https://developers.google.com/apps-script/reference/forms/item#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `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 a `https://developers.google.com/apps-script/reference/forms/section-header-item`).

#### Parameters

| Name | Type | Description |
|---|---|---|
| `title` | `String` | the new title or header text |

#### Return


`https://developers.google.com/apps-script/reference/forms/item#` --- this `https://developers.google.com/apps-script/reference/forms/item#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/forms.currentonly`
- `https://www.googleapis.com/auth/forms`