Class InsertWidget

InsertWidget

A builder for InsertWidget objects. Developers cans insert a widget into a card by passing a InsertWidget to ModifyCard

Only available for Google Workspace add-ons that extend Google Workspace Studio.

Sample usage:

constnewWidget=CardService.newDecoratedText().setText('New Widget');
constinsertWidget=AddOnsResponseService.newInsertWidget()
.insertAboveWidget('sample_id')
.setWidget(newWidget);
constmodifyCard=AddOnsResponseService.newModifyCard().setInsertWidget(insertWidget);

Methods

MethodReturn typeBrief description
insertAboveWidget(widgetId) InsertWidget Sets the widget ID, and the new widget is inserted above the widget with the given ID.
insertBelowWidget(widgetId) InsertWidget Sets the widget ID, and the new widget is inserted below the widget with the given ID.
setWidget(widget) InsertWidget Sets the Widget to be inserted.

Detailed documentation

insertAboveWidget(widgetId)

Sets the widget ID, and the new widget is inserted above the widget with the given ID. An error is thrown if the widget ID is not found.

Parameters

NameTypeDescription
widgetIdStringThe ID of the widget to insert above.

Return

InsertWidget — The insert widget object, for chaining.


insertBelowWidget(widgetId)

Sets the widget ID, and the new widget is inserted below the widget with the given ID. An error is thrown if the widget ID is not found.

Parameters

NameTypeDescription
widgetIdStringThe ID of the widget to insert below.

Return

InsertWidget — The insert widget object, for chaining.


setWidget(widget)

Sets the Widget to be inserted. An error is thrown if there is a existing widget with the same ID.

Parameters

NameTypeDescription
widgetWidget The widget to be inserted.

Return

InsertWidget — The insert widget object, for chaining.

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

Last updated 2025年12月03日 UTC.