Class CardWithId
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
CardWithId
ตัวสร้างสำหรับออบเจ็กต์ CardWithId
คลาสนี้เป็นตัวระบุที่ไม่ซ้ำกันสำหรับการ์ดในข้อความเมื่อส่งการ์ดหลายใบ
ใช้ได้กับแอป Google Chat เท่านั้น ไม่พร้อมใช้งานสำหรับส่วนเสริมของ Google Workspace
const cardSection = CardService.newCardSection();
cardSection.addWidget(
CardService.newTextParagraph().setText('This is a text paragraph widget.'),
);
const card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Card title'))
.addSection(cardSection)
.build();
const cardWithId =
CardService.newCardWithId().setCardId('card_id').setCard(card);
เอกสารประกอบโดยละเอียด
setCard(card)
ตั้งค่าการ์ดของ cardWithId
const cardHeader = CardService.newCardHeader()
.setTitle('Card Header Title')
.setSubtitle('Card Header Subtitle');
const card = CardService.newCardBuilder().setHeader(cardHeader).build();
const cardWithId = CardService.newCardWithId().setCard(card);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
card | Card | Card ที่จะใช้ |
รีเทิร์น
CardWithId
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setCardId(id)
ตั้งค่ารหัสบัตรที่ไม่ซ้ำกันของ cardWithId
const cardWithId = CardService.newCardWithId();
// Sets the card ID of the cardWithId.
cardWithId.setCardId('card_id');
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
id | String | ข้อความที่จะใช้ |
รีเทิร์น
CardWithId
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eCardWithId\u003c/code\u003e is a builder for creating cards with unique identifiers, specifically for use in Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eIt allows developers to set a card's content using \u003ccode\u003esetCard()\u003c/code\u003e and assign a unique ID using \u003ccode\u003esetCardId()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis functionality is crucial when sending multiple cards within a single message, enabling individual card identification and management.\u003c/p\u003e\n"],["\u003cp\u003eThis feature is not available for Google Workspace Add-ons.\u003c/p\u003e\n"]]],["`CardWithId` objects are unique identifiers for cards in messages, specifically for Google Chat apps. They are built using `CardService.newCardWithId()`. The core actions involve using `setCard(card)` to assign a `Card` object to the `CardWithId`, and `setCardId(id)` to assign a unique string identifier to the `CardWithId`. Both `setCard` and `setCardId` are chainable methods and are only available for Google Chat apps.\n"],null,["# Class CardWithId\n\nCardWithId\n\nA builder for [CardWithId](#) objects. This class is a unique identifier for a card in a\nmessage when sending multiple cards.\n\nOnly available for Google Chat apps. Not available for Google Workspace add-ons.\n\n```javascript\nconst cardSection = CardService.newCardSection();\ncardSection.addWidget(\n CardService.newTextParagraph().setText('This is a text paragraph widget.'),\n);\n\nconst card = CardService.newCardBuilder()\n .setHeader(CardService.newCardHeader().setTitle('Card title'))\n .addSection(cardSection)\n .build();\n\nconst cardWithId =\n CardService.newCardWithId().setCardId('card_id').setCard(card);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------|-----------------|--------------------------------------------------|\n| [setCard(card)](#setCard(Card)) | [CardWithId](#) | Sets the card of the `card``With``Id`. |\n| [setCardId(id)](#setCardId(String)) | [CardWithId](#) | Sets the unique card ID of the `card``With``Id`. |\n\nDetailed documentation\n----------------------\n\n### `set``Card(card)`\n\nSets the card of the `card``With``Id`.\n\n```javascript\nconst cardHeader = CardService.newCardHeader()\n .setTitle('Card Header Title')\n .setSubtitle('Card Header Subtitle');\n\nconst card = CardService.newCardBuilder().setHeader(cardHeader).build();\n\nconst cardWithId = CardService.newCardWithId().setCard(card);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|--------------------------------------------------|--------------------------------------------------------------|\n| `card` | [Card](/apps-script/reference/card-service/card) | The [Card](/apps-script/reference/card-service/card) to use. |\n\n#### Return\n\n\n[CardWithId](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Card``Id(id)`\n\nSets the unique card ID of the `card``With``Id`.\n\n```javascript\nconst cardWithId = CardService.newCardWithId();\n\n// Sets the card ID of the cardWithId.\ncardWithId.setCardId('card_id');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|------|----------|------------------|\n| `id` | `String` | The text to use. |\n\n#### Return\n\n\n[CardWithId](#) --- This object, for chaining."]]