google-apps-script - 在 newSelectionInput OnChangeAction 上将部分小部件动态添加到 Card 中

标签 google-apps-script gmail-addons google-apps-script-addon

我正在尝试在 newSelectionInput OnChangeAction 上动态地向 Card/CardService 添加一个部分小部件,该卡已经添加。

我没有在 Google 上看到任何关于如何实现这种行为的文档。

有人可以指导我找到正确的文档或我如何做到这一点。

谢谢

最佳答案

我们可以从卡片中添加/删除一个部分,该部分已经内置在输入字段的 onchange 操作中。

function getCard(addSection) {

 // this is your function to build the card. The initial "getCard" function call does not have any parameter passed, so it will be treated as "false". Hence no section will be added 

 addSection = addSection || false;
 
 if(addSection) {
 // add your section here
 }
 .....
 return card;
}

function OnChangeAction() {
  var card = getCard(true);
  return CardService.newActionResponseBuilder().setNavigation(CardService.newNavigation().updateCard(card)).build()
}


我希望这能解决你的问题。

关于google-apps-script - 在 newSelectionInput OnChangeAction 上将部分小部件动态添加到 Card 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47441281/

相关文章:

image - 如何在收到的 Gmail 邮件中插入图像

javascript - 刚刚发送的 Gmail 上返回的 Gmail 线程为 'undefined'

gmail - Gmail卡服务中的密码类型字段

unit-testing - 测试 Gmail 插件

google-apps-script - 如何在回调中判断 SelectionInput 复选框是否被选中?

google-apps-script - 以前工作的脚本现在与 onOpen 和 onInstall 有问题;事件并不总是触发

google-apps-script - 带有工作表插件的 Google Apps 脚本 PERMISSION_DENIED

google-apps-script - 用于添加和编辑/更新 Gmail 联系人的 Google 电子表格

google-apps-script - G Suite 插件拒绝连接到驱动器?如何解决 "drive.google.com refused to connect"错误?

google-apps-script - 如何在 Google 脚本代码中将脚本更改为 AuthMode.LIMITED?