Page Summary
-
DatePicker is an input field for selecting a date in Google Workspace add-ons and Google Chat apps.
-
Key methods include setting the field name, title, and default value, as well as defining an action when the input changes.
-
The
setValueInMsSinceEpochmethod can accept the default date value as either a number or a string representing milliseconds since the epoch.
An input field that allows inputing a date.
Available for Google Workspace add-ons and Google Chat apps.
const dateTimePicker = CardService . newDatePicker () . setTitle ( 'Enter the date.' ) . setFieldName ( 'date_field' ) // Set default value as Jan 1, 2018 UTC. Either a number or string is // acceptable. . setValueInMsSinceEpoch ( 1514775600 ) . setOnChangeAction ( CardService . newAction (). setFunctionName ( 'handleDateTimeChange' ), );
Methods
| Method | Return type | Brief description |
|---|---|---|
Widget
|
Adds the event action that can be performed on the widget. | |
Date
|
Sets the field name that identifies this picker in the event object that is generated when there is a UI interaction. | |
Widget
|
Sets the unique ID assigned that's used to identify the widget to be mutated. | |
Date
|
Sets an Action
that the script performs whenever the picker input changes. |
|
Date
|
Sets the title displayed above the input field. | |
Date
|
Sets the prefilled value to be set in the input field. | |
Date
|
Sets the prefilled value to be set in the input field. | |
Widget
|
Sets the visibility of the widget. |
Detailed documentation
add
Event
Action(eventAction)
Adds the event action that can be performed on the widget.
Parameters
| Name | Type | Description |
|---|---|---|
event
|
Event
|
The Event
to be added. |
Return
Widget
— The Object, for chaining.
set
Field
Name(fieldName)
Sets the field name that identifies this picker in the event object that is generated when there is a UI interaction. The field name is visible to the user. Required; the specified field name must be unique.
Parameters
| Name | Type | Description |
|---|---|---|
field
|
String
|
The name to assign to this input. |
Return
Date
— This picker, for chaining.
set
Id(id)
Sets the unique ID assigned that's used to identify the widget to be mutated. Widget mutation is only supported in Add-Ons.
Parameters
| Name | Type | Description |
|---|---|---|
id
|
String
|
The id of the widget, with a limit of 64 characters and in format of `[a-zA-Z0-9-]+`. |
Return
Widget
— This object, for chaining.
set
On
Change
Action(action)
Sets an Action
that the script performs whenever the picker input changes.
Parameters
| Name | Type | Description |
|---|---|---|
action
|
Action
|
The action to take. |
Return
Date
— This picker, for chaining.
set
Title(title)
Sets the title displayed above the input field.
Parameters
| Name | Type | Description |
|---|---|---|
title
|
String
|
The input field title. |
Return
Date
— This picker, for chaining.
set
Value
In
Ms
Since
Epoch(valueMsEpoch)
Sets the prefilled value to be set in the input field.
Parameters
| Name | Type | Description |
|---|---|---|
value
|
Number
|
The default value placed in the input as a number, in milliseconds since the epoch. Only the date of the epoch time is used, and the time of the epoch time is discarded. It is always represented as a string in the form callback parameters. |
Return
Date
— This picker, for chaining.
set
Value
In
Ms
Since
Epoch(valueMsEpoch)
Sets the prefilled value to be set in the input field.
Parameters
| Name | Type | Description |
|---|---|---|
value
|
String
|
The default value placed in the input as a string, in milliseconds since the epoch. Only the date of the epoch time is used, and the time of the epoch time is discarded. It is always represented as a string in the form callback parameters. |
Return
Date
— This picker, for chaining.
set
Visibility(visibility)
Sets the visibility of the widget. The default value is `VISIBLE`.
Parameters
| Name | Type | Description |
|---|---|---|
visibility
|
Visibility
|
The Visibility
of the widget. |
Return
Widget
— The Object, for chaining.

