本文介绍了Google脚本gmail addon更新TextInput的值,在更改函数上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

下面的代码我试过了,

  var client_action = CardService.newAction()。setFunctionName('clientId_callBack'); 
CardService.newTextInput()
.setFieldName(clientId)
.setTitle(请输入clinet id)
.setOnChangeAction(client_action)

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

预先致谢

解决方案

这项工作如何?我认为可能有其他方法。所以请把它想成几个答案之一。在此示例脚本中,输入 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()
}

函数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()
}
}




I have create simple gmail addon using google script,in that i have struggle here,

how to update textinput value on setOnChangeAction Method ,i have checked the document, i couldn't find any methods

The below code i have tried,

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";
}

Thanks in advance

解决方案

How about this work around? I think that there may be other ways. So please think of this as one of several answers. In this sample script, when the value of foo is inputted, the text input is reconstructed using CardBuilder. When you use this script, as a test, please input foo. This is a very simple snippet, so please modify this for your environment.

Sample script :

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

If I misunderstand your question, I'm sorry.

这篇关于Google脚本gmail addon更新TextInput的值,在更改函数上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 16:20