Class CardWithId
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
CartaConId
Un generatore di oggetti CardWithId
. Questa classe è un identificatore univoco per una scheda in un messaggio quando vengono inviate più schede.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi di 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);
Documentazione dettagliata
setCard(card)
Imposta la scheda del 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);
Parametri
Nome | Tipo | Descrizione |
card | Card | Il Card da utilizzare. |
Invio
CardWithId
: questo oggetto, per l'accodamento.
setCardId(id)
Imposta l'ID carta univoco del cardWithId
.
const cardWithId = CardService.newCardWithId();
// Sets the card ID of the cardWithId.
cardWithId.setCardId('card_id');
Parametri
Nome | Tipo | Descrizione |
id | String | Il testo da utilizzare. |
Invio
CardWithId
: questo oggetto, per l'accodamento.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 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."]]