Class CardWithId
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
CardWithId
Ein Builder für CardWithId
-Objekte. Diese Klasse ist eine eindeutige Kennung für eine Karte in einer Nachricht, wenn mehrere Karten gesendet werden.
Nur für Google Chat-Apps verfügbar. Nicht verfügbar für Google Workspace-Add-ons.
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);
Detaillierte Dokumentation
setCard(card)
Legt die Karte des cardWithId
fest.
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
Name | Typ | Beschreibung |
card | Card | Der zu verwendende Card . |
Rückflug
CardWithId
– dieses Objekt, zur Verkettung
setCardId(id)
Die eindeutige Karten-ID der cardWithId
.
const cardWithId = CardService.newCardWithId();
// Sets the card ID of the cardWithId.
cardWithId.setCardId('card_id');
Parameter
Name | Typ | Beschreibung |
id | String | Der zu verwendende Text. |
Rückflug
CardWithId
– dieses Objekt, zur Verkettung
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-07-26 (UTC).
[null,null,["Zuletzt aktualisiert: 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."]]