Class CardWithId
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
CardWithId
Builder untuk objek CardWithId
. Class ini adalah ID unik untuk kartu dalam
pesan saat mengirim beberapa kartu.
Hanya tersedia untuk aplikasi Google Chat. Tidak tersedia untuk add-on 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);
Dokumentasi mendetail
setCard(card)
Menetapkan kartu 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);
Parameter
Nama | Jenis | Deskripsi |
card | Card | Card yang akan digunakan. |
Pulang pergi
CardWithId
— Objek ini, untuk pembuatan rantai.
setCardId(id)
Menetapkan ID kartu unik cardWithId
.
const cardWithId = CardService.newCardWithId();
// Sets the card ID of the cardWithId.
cardWithId.setCardId('card_id');
Parameter
Nama | Jenis | Deskripsi |
id | String | Teks yang akan digunakan. |
Pulang pergi
CardWithId
— Objek ini, untuk pembuatan rantai.
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-26 UTC.
[null,null,["Terakhir diperbarui pada 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."]]