Class PlatformDataSource

  • PlatformDataSource is used for populating items in a multiselect menu within a SelectionInput widget.

  • This feature is exclusively available for Google Chat apps and cannot be used with Google Workspace add-ons.

  • You can set the data source usingsetCommonDataSource for Google Workspace data orsetHostAppDataSource for populating spaces in a multiselect menu.

PlatformDataSource

For aSelectionInput widget that uses a multiselect menu, a data source from GoogleWorkspace. Used to populate items in a multiselect menu.

constplatformDataSource=CardService.newPlatformDataSource().setCommonDataSource(CardService.CommonDataSource.USER,);constmultiSelect=CardService.newSelectionInput().setType(CardService.SelectionInputType.MULTI_SELECT).setFieldName('contacts').setTitle('Selected contacts').setMultiSelectMaxSelectedItems(5).setMultiSelectMinQueryLength(1).setPlatformDataSource(platformDataSource);

Only available for Google Chat apps. Not available for Google Workspace add-ons.

Methods

MethodReturn typeBrief description
setCommonDataSource(commonDataSource)PlatformDataSourceSets the data source from Google Workspace.
setDriveDataSourceSpec(driveDataSourceSpec)PlatformDataSourceSets the drive data source spec from Google Workspace.
setHostAppDataSource(hostAppDataSource)PlatformDataSourceUsed to populate spaces in multiselect menu.

Detailed documentation

setCommonDataSource(commonDataSource)

Sets the data source from Google Workspace.

constplatformDataSource=CardService.newPlatformDataSource().setCommonDataSource(CardService.CommonDataSource.USER,);constmultiSelect=CardService.newSelectionInput().setType(CardService.SelectionInputType.MULTI_SELECT).setFieldName('contacts').setTitle('Selected contacts').setMultiSelectMaxSelectedItems(5).setMultiSelectMinQueryLength(1).setPlatformDataSource(platformDataSource);
Only available for Google Chat apps. Not available for Google Workspace add-ons.

Parameters

NameTypeDescription
commonDataSourceCommonDataSourceThe data source to be set.

Return

PlatformDataSource — This object, for chaining.


setDriveDataSourceSpec(driveDataSourceSpec)

Sets the drive data source spec from Google Workspace.

constdriveDataSourceSpec=CardService.newDriveDataSourceSpec().addItemType(CardService.DriveItemType.DOCUMENTS).addItemType(CardService.DriveItemType.FORMS);constplatformDataSource=CardService.newPlatformDataSource().setCommonDataSource(CardService.CommonDataSource.DRIVE).setDriveDataSourceSpec(driveDataSourceSpec);constmultiSelect=CardService.newSelectionInput().setType(CardService.SelectionInputType.MULTI_SELECT).setFieldName('files').setTitle('Drive Files').setMultiSelectMaxSelectedItems(5).setMultiSelectMinQueryLength(1).setPlatformDataSource(platformDataSource);
Available for Google Chat apps. For Google Workspace add-ons, it needs to addPer-fileaccess scope(https://www.googleapis.com/auth/drive.file) to manifest.

Parameters

NameTypeDescription
driveDataSourceSpecDriveDataSourceSpecThe drive data source spec to be set.

Return

PlatformDataSource — This object, for chaining.


setHostAppDataSource(hostAppDataSource)

Used to populate spaces in multiselect menu.

constchatSpaceDataSource=CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);constchatClientDataSource=CardService.newChatClientDataSource().setSpaceDataSource(chatSpaceDataSource);consthostAppDataSource=CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);constplatformDataSource=CardService.newPlatformDataSource().setHostAppDataSource(hostAppDataSource);constmultiSelect=CardService.newSelectionInput().setType(CardService.SelectionInputType.MULTI_SELECT).setFieldName('contacts').setTitle('Selected contacts').setMultiSelectMaxSelectedItems(5).setMultiSelectMinQueryLength(1).setPlatformDataSource(platformDataSource);
Only available for Google Chat apps. Not available for Google Workspace add-ons.

Parameters

NameTypeDescription
hostAppDataSourceHostAppDataSourceThe data source to be set.

Return

PlatformDataSource — This object, for chaining.

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-03 UTC.