4

我已经使用谷歌脚本创建了简单的 gmail 插件,因为我在这里遇到了困难,

如何更新setOnChangeAction方法上的 textinput 值,我检查了文档,我找不到任何方法

我尝试过的以下代码,

var client_action = CardService.newAction().setFunctionName('clientId_callBack');
CardService.newTextInput()
  .setFieldName("clientId")
  .setTitle("Please enter clinet id")
  .setOnChangeAction(client_action)

function clientId_callBack(e){
  Logger.log("%s",JSON.stringify(e))
  e.formInput.clientId = "updatedValue";
}

提前致谢

4

1 回答 1

0

这个工作怎么样?我认为可能还有其他方法。因此,请将此视为几个答案之一。在此示例脚本中,当foo输入 的值时,使用 CardBuilder 重建文本输入。当您使用此脚本时,作为测试,请输入foo. 这是一个非常简单的片段,因此请根据您的环境对其进行修改。

示例脚本:

function buildAddOn() {
  var card = CardService.newCardBuilder();
  card.setHeader(CardService.newCardHeader().setTitle("Sample"));
  var section = CardService.newCardSection();
  var action = CardService.newAction().setFunctionName('changeValue');
  section.addWidget(CardService.newTextInput().setFieldName("value").setTitle("Input \"foo\" as a value.").setOnChangeAction(action))
  return card.addSection(section).build()
}

function changeValue(e) {
  if (e.formInput.value == "foo") {
    var card = CardService.newCardBuilder();
    card.setHeader(CardService.newCardHeader().setTitle("Changed"));
    var section = CardService.newCardSection();
    var action = CardService.newAction().setFunctionName('getValue1');
    section.addWidget(CardService.newTextInput().setFieldName("value").setTitle("Got \"foo\".").setOnChangeAction(action).setValue("bar"))
    return card.addSection(section).build()
  }
}

如果我误解了你的问题,我很抱歉。

于 2018-02-11T02:21:37.343 回答