我使用google脚本创建了简单的gmail插件,因为我在这里很难,
当我们执行某些操作时如何获取textinput值,我检查了文档,我找不到任何方法
以下代码我试过了,
var card = CardService.newCardBuilder();
card.setHeader(CardService.newCardHeader().setTitle("Login Here"));
var section = CardService.newCardSection()
var cleint_id_Input = CardService.newTextInput()
.setFieldName("client_id")
.setTitle("Please enter clinet id")
var username_Input = CardService.newTextInput()
.setFieldName("username")
.setTitle("Please enter username")
var password_Input = CardService.newTextInput()
.setFieldName("password")
.setTitle("Please enter password")
section.addWidget(cleint_id_Input)
section.addWidget(username_Input)
section.addWidget(password_Input)
Logger.log("Input Value%s",cleint_id_Input)
//Login action button
var action = CardService.newAction().setFunctionName('loginCallback');
section.addWidget(CardService.newTextButton().setText('Login').setOnClickAction(action))
card.addSection(section)
我需要“loginCallback”函数中的inputText值
提前致谢
答案 0 :(得分:7)
您可以将输入的值检索为JSON对象。修改后的脚本检索输入的值并显示它们。所以请根据您的环境进行修改。
function buildAddOn() {
var card = CardService.newCardBuilder();
card.setHeader(CardService.newCardHeader().setTitle("Login Here"));
var section = CardService.newCardSection()
var cleint_id_Input = CardService.newTextInput()
.setFieldName("client_id")
.setTitle("Please enter clinet id")
var username_Input = CardService.newTextInput()
.setFieldName("username")
.setTitle("Please enter username")
var password_Input = CardService.newTextInput()
.setFieldName("password")
.setTitle("Please enter password")
section.addWidget(cleint_id_Input)
section.addWidget(username_Input)
section.addWidget(password_Input)
Logger.log("Input Value%s",cleint_id_Input)
//Login action button
var action = CardService.newAction().setFunctionName('loginCallback');
section.addWidget(CardService.newTextButton().setText('Login').setOnClickAction(action))
card.addSection(section)
return card.build() // Added
}
// Added
function loginCallback(e) {
return CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('sample'))
.addSection(CardService.newCardSection().addWidget(
CardService.newKeyValue().setContent(JSON.stringify(e.formInput, null, " ")))
)
.build();
}
在您的情况下,e
的{{1}}如下。
loginCallback(e)
如果我误解了你的问题,我很抱歉。