Class PlatformDataSource

平台資料來源

如果 SelectionInput 小工具使用多選選單,則資料來源必須來自 Google Workspace。用於在多選選單中填入項目。

const platformDataSource =
    CardService.newPlatformDataSource().setCommonDataSource(
        CardService.CommonDataSource.USER,
    );

const multiSelect = CardService.newSelectionInput()
                        .setType(CardService.SelectionInputType.MULTI_SELECT)
                        .setFieldName('contacts')
                        .setTitle('Selected contacts')
                        .setMultiSelectMaxSelectedItems(5)
                        .setMultiSelectMinQueryLength(1)
                        .setPlatformDataSource(platformDataSource);

僅適用於 Google Chat 應用程式。不適用於 Google Workspace 外掛程式。

方法

方法傳回類型簡短說明
setCommonDataSource(commonDataSource)PlatformDataSource設定 Google Workspace 的資料來源。
setDriveDataSourceSpec(driveDataSourceSpec)PlatformDataSource從 Google Workspace 設定雲端硬碟資料來源規格。
setHostAppDataSource(hostAppDataSource)PlatformDataSource用於在多選選單中填入空格。

內容詳盡的說明文件

setCommonDataSource(commonDataSource)

設定 Google Workspace 的資料來源。

const platformDataSource =
    CardService.newPlatformDataSource().setCommonDataSource(
        CardService.CommonDataSource.USER,
    );

const multiSelect = CardService.newSelectionInput()
                        .setType(CardService.SelectionInputType.MULTI_SELECT)
                        .setFieldName('contacts')
                        .setTitle('Selected contacts')
                        .setMultiSelectMaxSelectedItems(5)
                        .setMultiSelectMinQueryLength(1)
                        .setPlatformDataSource(platformDataSource);
僅適用於 Google Chat 擴充應用程式。不適用於 Google Workspace 外掛程式。

參數

名稱類型說明
commonDataSourceCommonDataSource要設定的資料來源。

回攻員

PlatformDataSource - 這個物件,用於鏈結。


setDriveDataSourceSpec(driveDataSourceSpec)

從 Google Workspace 設定雲端硬碟資料來源規格。

const driveDataSourceSpec =
    CardService.newDriveDataSourceSpec()
      .addItemType(CardService.DriveItemType.DOCUMENTS)
      .addItemType(CardService.DriveItemType.FORMS);

const platformDataSource =
    CardService.newPlatformDataSource().setCommonDataSource(
        CardService.CommonDataSource.DRIVE
    ).setDriveDataSourceSpec(driveDataSourceSpec);

const multiSelect = CardService.newSelectionInput()
                        .setType(CardService.SelectionInputType.MULTI_SELECT)
                        .setFieldName('files')
                        .setTitle('Drive Files')
                        .setMultiSelectMaxSelectedItems(5)
                        .setMultiSelectMinQueryLength(1)
                        .setPlatformDataSource(platformDataSource);
適用於 Google Chat 應用程式。如果是 Google Workspace 外掛程式,則需要在資訊清單中新增每個檔案的存取範圍(https://www.googleapis.com/auth/drive.file)。

參數

名稱類型說明
driveDataSourceSpecDriveDataSourceSpec要設定的雲端硬碟資料來源規格。

回攻員

PlatformDataSource - 這個物件,用於鏈結。


setHostAppDataSource(hostAppDataSource)

用於在多選選單中填入空格。

const chatSpaceDataSource =
    CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);

const chatClientDataSource =
    CardService.newChatClientDataSource().setSpaceDataSource(
        chatSpaceDataSource);

const hostAppDataSource =
    CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);

const platformDataSource =
    CardService.newPlatformDataSource().setHostAppDataSource(hostAppDataSource);

const multiSelect = CardService.newSelectionInput()
                        .setType(CardService.SelectionInputType.MULTI_SELECT)
                        .setFieldName('contacts')
                        .setTitle('Selected contacts')
                        .setMultiSelectMaxSelectedItems(5)
                        .setMultiSelectMinQueryLength(1)
                        .setPlatformDataSource(platformDataSource);
僅適用於 Google Chat 擴充應用程式。不適用於 Google Workspace 外掛程式。

參數

名稱類型說明
hostAppDataSourceHostAppDataSource要設定的資料來源。

回攻員

PlatformDataSource - 這個物件,用於鏈結。