A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/card-service/text-input below:

Class TextInput | Apps Script

Class TextInput

Stay organized with collections Save and categorize content based on your preferences.

TextInput

A input field widget that accepts text input.

Supports form submission validation. When Action.setAllWidgetsAreRequired(allWidgetsAreRequired) is set to true or this widget is specified through Action.addRequiredWidget(requiredWidget), the submission action is blocked unless a value is entered.

Available for Google Workspace add-ons and Google Chat apps.

const textInput = CardService.newTextInput()
                      .setFieldName('text_input_form_input_key')
                      .setTitle('Text input title')
                      .setHint('Text input hint');
Detailed documentation setFieldName(fieldName)

Sets the key that identifies this text input in the event object that is generated when there is a UI interaction. Not visible to the user. Required, must be unique.

Parameters Name Type Description fieldName String The key that is used to identify this input. Return

TextInput — This object, for chaining.

setHint(hint)

Sets a hint for the text input. Used to give the user extra guidance on what to input. For example, a hint could describe formatting ("xxx-xxx-xxxx") for a phone number field.

Parameters Name Type Description hint String The text hint to display below the input field. This text is always visible. Return

TextInput — This object, for chaining.

setMultiline(multiline)

Sets whether the input text shows on one line or multiple lines.

Parameters Name Type Description multiline Boolean The multiline setting. Return

TextInput — This object, for chaining.

setOnChangeAction(action)

Sets an action to be performed whenever the text input changes.

Parameters Name Type Description action Action The action to take. Return

TextInput — This object, for chaining.

setSuggestions(suggestions)

Sets the suggestions for autocompletion in the text field.

Parameters Name Type Description suggestions Suggestions The collection of suggestions to use. Return

TextInput — This object, for chaining.

setSuggestionsAction(suggestionsAction)

Sets the callback action to fetch suggestions based on user input for autocompletion. The Action parameter must specify a callback function that returns a SuggestionsResponse object.

const action = CardService.newAction()
                   .setFunctionName('suggestionCallback')
                   .setParameters({numSuggestions: 3});

CardService.newTextInput()
    .setFieldName('option-field')
    .setTitle('Option Selected')
    .setSuggestionsAction(action);

// ...

function suggestionCallback(e) {
  const suggestions = CardService.newSuggestions();
  const numSuggestions = Number.parseInt(e.parameter.numSuggestions);
  for (let i = 1; i <= numSuggestions; i++) {
    suggestions.addSuggestion(`Suggestion ${i}`);
  }
  return CardService.newSuggestionsResponseBuilder()
      .setSuggestions(suggestions)
      .build();
}
Parameters Name Type Description suggestionsAction Action The action that fetches suggestions for this input. Return

TextInput — This object, for chaining.

setTitle(title)

Sets the title to be shown above the input field. Required.

Parameters Name Type Description title String The text label for this input. Return

TextInput — This object, for chaining.

setValidation(validation)

Sets the validation rule for this widget.

const validation = CardService.newValidation().setCharacterLimit('10').setType(
    CardService.InputType.TEXT);

const input = CardService.newTextInput()
                  .setFieldName('text_name_xxx1')
                  .setTitle('Max 10 characters')
                  .setValidation(validation);
Parameters Return

TextInput — This object, for chaining.

setValue(value)

Sets the pre-filled value to be set in the input field.

Parameters Name Type Description value String The default value placed in the input. It is always represented as a string in the form callback parameters. Return

TextInput — 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."],[[["TextInput is a UI element that allows users to input text within Google Workspace Add-ons and Google Chat apps."],["It offers various customization options, including setting titles, hints, pre-filled values, and handling multi-line input."],["Developers can set actions triggered by text input changes or employ auto-completion with suggestions."],["`setFieldName` is a required method used to identify the TextInput element in event objects for data retrieval."],["Each customization method for the TextInput object returns the object itself, enabling method chaining for streamlined configuration."]]],["The `TextInput` widget allows text input and supports form validation, blocking submission if required fields are empty. Key actions include setting a unique field name (`setFieldName`), providing user hints (`setHint`), enabling multiline input (`setMultiline`), and defining actions on text change (`setOnChangeAction`). Autocompletion is supported via suggestions (`setSuggestions`) or a callback to fetch them (`setSuggestionsAction`). You can set a title (`setTitle`), validation rules (`setValidation`), and pre-fill values (`setValue`).\n"]]


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