Stay organized with collections Save and categorize content based on your preferences.
ActionAn action that enables interactivity within UI elements. The action does not happen directly on the client but rather invokes an Apps Script callback function with optional parameters.
Available for Google Workspace add-ons and Google Chat apps.
const image = CardService.newImage().setOnClickAction( CardService.newAction().setFunctionName('handleImageClick').setParameters({ imageSrc: 'carImage' }), );Methods Deprecated methods Detailed documentation
setFunctionName(functionName)
Sets the name of the callback function to be called. Required.
Parameters Name Type DescriptionfunctionName
String
The name of the function. You can use functions from included libraries, such as Library.libFunction1
. Return
Action
— This object, for chaining.
setInteraction(interaction)
Sets the interaction with a user, only required when opening a dialog. If unspecified, the app responds by executing an Action
like opening a link or running a function—as normal.
Only available for Google Chat apps. Not available for Google Workspace add-ons.
const action = CardService.newAction() .setFunctionName('handleDialog') .setInteraction(CardService.Interaction.OPEN_DIALOG);Parameters Name Type Description
interaction
Interaction
The interaction to specify. Return
Action
— This object, for chaining.
setLoadIndicator(loadIndicator)
Sets the loading indicator that displays while the action is in progress.
Parameters Name Type DescriptionloadIndicator
LoadIndicator
The indicator to display. Return
Action
— This object, for chaining.
setParameters(parameters)
Allows custom parameters to be passed to the callback function. Optional.
Parameters Name Type Descriptionparameters
Object
Both keys and values must be strings. Return
Action
— This object, for chaining.
setPersistValues(persistValues)
Indicates whether form values are determined by the client's values or the server's values after an action response updates the form's Card
. When set to true
, the client's values persist after the server response. When set to false
, the server's values overwrite the form values. Defaults to false
.
Persisting the client values helps prevent situations where a form changes unexpectedly after a user makes an edit. For example, if a user makes an edit to a TextInput
after submitting a form, but before the server responds. If the values are persisted, the edit the user made remains after the server response updates the Card
; otherwise the form value returns to the value that the user originally submitted to the form.
Persisting client values can interfere with your script's ability to clear form fields or override form values, so avoid turning on persistence for that type of functionality. Without persistence, it's recommended that you use the LoadIndicator.SPINNER
for events, because this locks the UI and prevents user edits before the server responds. Alternatively, you can use LoadIndicator.NONE
and make sure every element in the form has an onChange action.
// Creates a button with an action that persists the client's values as the // on-click action. const button = CardService.newTextButton() .setText('Create notification') .setOnClickAction( CardService.newAction().setPersistValues(true).setFunctionName( 'functionName'), );Parameters Name Type Description
persistValues
Boolean
Whether to persist values. Defaults to false
. Return
Action
— This object, for chaining.
setMethodName(functionName)
Deprecated. Legacy alias for setFunctionName(functionName)
.
functionName
String
The name of the function. You can use functions from included libraries, such as Library.libFunction1
. Return
Action
— This object, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-01-30 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-30 UTC."],[[["Actions enable interactivity within UI elements by invoking Apps Script callback functions with optional parameters."],["They are available for Google Workspace Add-ons and Google Chat apps."],["Developers can set the callback function, parameters, load indicator, and required widgets using the provided methods."],["Actions can persist form values from the client-side to maintain user edits after server responses."],["The `setMethodName` method is deprecated and should be replaced with `setFunctionName`."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4