簡體   English   中英

如何訪問 Google App 腳本中的 Card 部分輸入字段值?

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

我的卡片生成器看起來像

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();

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)
}

要從文本輸入中檢索估算值,您需要e.formInputs.name

例如,您的加載項可以找到用戶在eventObject.commentEventObject.formInputs object 中的 TextInput 小部件中輸入的文本。

為了給您一個想法,您可以嘗試以下操作:

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

有關更多詳細信息,您可以參考此文檔

參考: 事件對象

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM