Class HostAppDataSource
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
โฮสต์แหล่งข้อมูลแอป
สําหรับวิดเจ็ต SelectionInput
ที่ใช้เมนูแบบเลือกหลายรายการ แหล่งข้อมูลจากแอปพลิเคชัน Google Workspace แหล่งข้อมูลจะป้อนข้อมูลรายการตัวเลือกสำหรับเมนูแบบเลือกหลายรายการ
const chatSpaceDataSource =
CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);
const chatClientDataSource =
CardService.newChatClientDataSource().setSpaceDataSource(
chatSpaceDataSource);
const hostAppDataSource =
CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);
ใช้ได้กับแอป Google Chat เท่านั้น ไม่พร้อมใช้งานสำหรับส่วนเสริมของ Google Workspace
เอกสารประกอบโดยละเอียด
setChatDataSource(chatClientDataSource)
ตั้งค่าแหล่งข้อมูลจาก Google Chat
const chatSpaceDataSource =
CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);
const chatClientDataSource =
CardService.newChatClientDataSource().setSpaceDataSource(
chatSpaceDataSource);
const hostAppDataSource =
CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);
ใช้ได้กับแอป Google Chat เท่านั้น ไม่พร้อมใช้งานสำหรับส่วนเสริมของ Google Workspace
พารามิเตอร์
รีเทิร์น
HostAppDataSource
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eHostAppDataSource\u003c/code\u003e is used for populating selection items in a multiselect menu within a Google Chat app.\u003c/p\u003e\n"],["\u003cp\u003eIt leverages a data source from Google Chat, configured using \u003ccode\u003eChatClientDataSource\u003c/code\u003e and \u003ccode\u003eChatSpaceDataSource\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis functionality is exclusive to Google Chat apps and is not available for Google Workspace Add-ons.\u003c/p\u003e\n"],["\u003cp\u003eThe key method is \u003ccode\u003esetChatDataSource()\u003c/code\u003e, used for setting the Google Chat data source.\u003c/p\u003e\n"]]],["`HostAppDataSource` provides a data source for multiselect menus in Google Chat apps, using `SelectionInput`. It's created via `CardService.newHostAppDataSource()`. `setChatDataSource()` is used to specify the data source, which must be a `ChatClientDataSource`. In turn, `ChatClientDataSource` is configured with a `ChatSpaceDataSource`. Only available for Chat apps, it sets the data source for populating selection items within the menu, and returns the current `HostAppDataSource` object.\n"],null,["# Class HostAppDataSource\n\nHostAppDataSource\n\nFor a [SelectionInput](/apps-script/reference/card-service/selection-input) widget that uses a multiselect menu, a data source from a Google\nWorkspace application. The data source populates selection items for the multiselect menu.\n\n```javascript\nconst chatSpaceDataSource =\n CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);\n\nconst chatClientDataSource =\n CardService.newChatClientDataSource().setSpaceDataSource(\n chatSpaceDataSource);\n\nconst hostAppDataSource =\n CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);\n```\n\nOnly available for Google Chat apps. Not available for Google Workspace add-ons. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------------------|------------------------|----------------------------------------|\n| [setChatDataSource(chatClientDataSource)](#setChatDataSource(ChatClientDataSource)) | [HostAppDataSource](#) | Sets the data source from Google Chat. |\n\nDetailed documentation\n----------------------\n\n### `set``Chat``Data``Source(chatClientDataSource)`\n\nSets the data source from Google Chat.\n\n```javascript\nconst chatSpaceDataSource =\n CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);\n\nconst chatClientDataSource =\n CardService.newChatClientDataSource().setSpaceDataSource(\n chatSpaceDataSource);\n\nconst hostAppDataSource =\n CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);\n```\nOnly available for Google Chat apps. Not available for Google Workspace add-ons.\n\n#### Parameters\n\n| Name | Type | Description |\n|------------------------------|-------------------------------------------------------------------------------------|----------------------------|\n| `chat``Client``Data``Source` | [ChatClientDataSource](/apps-script/reference/card-service/chat-client-data-source) | The data source to be set. |\n\n#### Return\n\n\n[HostAppDataSource](#) --- This object, for chaining."]]