Restez organisé à l'aide des collections Enregistrez et classez les contenus selon vos préférences.
ActionRéponse
Objet de réponse pouvant être renvoyé à partir d'une fonction de rappel (par exemple, un gestionnaire de réponse de formulaire) pour effectuer une ou plusieurs actions sur le client. Certaines combinaisons d'actions ne sont pas acceptées.
// An action that opens a linkconstactionResponse=CardService.newActionResponseBuilder().setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com')).build();// An action that shows a notification.constnotificationActionResponse=CardService.newActionResponseBuilder().setNotification(CardService.newNotification().setText('Some info to display to user'),).build();// An action that shows an additional card. It also sets a flag to indicate that// the original state data has changed.constcardBuilder=CardService.newCardBuilder();// Build card ...constnavigationActionResponse=CardService.newActionResponseBuilder().setNavigation(CardService.newNavigation().pushCard(cardBuilder.build())).setStateChanged(true).build();
Imprime la représentation JSON de cet objet. Cette option est réservée au débogage.
Renvois
String
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eActionResponse\u003c/code\u003e enables callback functions to trigger actions like opening links, displaying notifications, and navigating between cards within Google Workspace add-ons.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use \u003ccode\u003eActionResponseBuilder\u003c/code\u003e methods to define these actions and control client-side behavior based on user interactions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eprintJson()\u003c/code\u003e method helps with debugging by providing the JSON representation of the \u003ccode\u003eActionResponse\u003c/code\u003e object.\u003c/p\u003e\n"]]],["The `ActionResponse` object enables client-side actions from callback functions. It supports actions like opening a link, displaying a notification, or showing a new card. `setOpenLink` opens a specified URL, `setNotification` displays text to the user, and `setNavigation` pushes a new card. `setStateChanged` indicates changes in original data. `printJson()` provides a JSON representation of the object for debugging. Certain action combinations may be unsupported.\n"],null,["ActionResponse\n\nThe response object that may be returned from a callback function (e.g., a form response handler)\nto perform one or more actions on the client. Some combinations of actions are not supported.\n\n```javascript\n// An action that opens a link\nconst actionResponse =\n CardService.newActionResponseBuilder()\n .setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com'))\n .build();\n\n// An action that shows a notification.\nconst notificationActionResponse = CardService.newActionResponseBuilder()\n .setNotification(\n CardService.newNotification().setText(\n 'Some info to display to user'),\n )\n .build();\n\n// An action that shows an additional card. It also sets a flag to indicate that\n// the original state data has changed.\n\nconst cardBuilder = CardService.newCardBuilder();\n// Build card ...\nconst navigationActionResponse = CardService.newActionResponseBuilder()\n .setNavigation(CardService.newNavigation().pushCard(\n cardBuilder.build()))\n .setStateChanged(true)\n .build();\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------|-------------|------------------------------------------------|\n| [printJson()](#printJson()) | `String` | Prints the JSON representation of this object. |\n\nDetailed documentation \n\n`print``Json()` \nPrints the JSON representation of this object. This is for debugging only.\n\nReturn\n\n\n`String`"]]