简体   繁体   English

如何访问 Google App 脚本中的 Card 部分输入字段值?

[英]How to access the Card section input field value in Google App Script?

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 Text Input 的文档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)
}

To retrieve the imputed value from a text input, you need e.formInputs.name :要从文本输入中检索估算值,您需要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.例如,您的加载项可以找到用户在eventObject.commentEventObject.formInputs object 中的 TextInput 小部件中输入的文本。

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参考: 事件对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Script Card Service datepicker 返回奇怪的值 - Google App Script Card Service datepicker returns strange value 如何在谷歌应用脚本中获取用户输入? - How to get user input in google app script? 谷歌工作表脚本使用按钮和输入字段增加活动单元格值 - google sheet script to increase active cell value with button and input field 如何使用Google App脚本访问子文件夹? - How to access to a subFolder with google app script? 如何在 Google Apps Script 中访问我的 HTML 文件的脚本部分中的模板变量? - How to access template variables in the script section of my HTML file in Google Apps Script? 如何在没有用户干预的情况下输入 Google Sheets App Script? - How to get input into Google Sheets App Script without user intervention? 如何更新/覆盖lastrow google app脚本中不在同一行中的输入 - How to update/ overwrite input in the same row not in lastrow google app script 如果谷歌应用程序脚本中的密码输入正确,如何导航到下一页 - how to navigate to the next page if a password input is correct in google app script Google App脚本-在输入文本框中输入密钥-如何捕获或禁用? - Google App Script - Enter key in input textbox - how to catch or disable? 如何授予普通用户对Google应用程序脚本的受限adminsdk访问权限? - How to grant a regular user limited adminsdk access for a google app script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM