Home > Net >  How to access the Card section input field value in Google App Script?
How to access the Card section input field value in Google App Script?

Time:01-20

My card builder looks something like

function createSelectionCard(e) {
  var builder = CardService.newCardBuilder();

  builder.addSection(CardService.newCardSection()
    .addWidget(CardService.newTextInput()
      .setFieldName("text_input_form_input_key")
      .setTitle("Enter Value")
      .setValue('Test'))
....
return builder.build();

The documentation for Text Input says that setFieldName Sets the key that identifies this text input in the event object that is generated when there is a UI interaction but using e.text_input_form_input_key always results to a null value

function Embed(e) {
...
  presentation.getSelection().getCurrentPage().insertImage(dataBlob)
    .setDescription(e.text_input_form_input_key)
}

CodePudding user response:

To retrieve the imputed value from a text input, you need e.formInputs.name:

For example, your add-on can locate the text a user has entered into a TextInput widget in the eventObject.commentEventObject.formInputs object.

To give you an idea, you can try with the following:

e.commonEventObject.formInputs.text_input_form_input_key.stringInputs.value[0]

For more details, you can refer to this documentation.

References: Event objects

  • Related