小编Moh*_*nna的帖子

如何使用 Apps 脚本重新启动/更新/刷新卡

我在使用 Apps 脚本做很多场景时做噩梦,但没有任何效果!我有一个函数可以让GET请求返回一组卡片。现在,有时我需要再次刷新此卡以获取新内容。

function listTemplatesCards(){
  var getAllTemplates = getTemplates();
  var allTemplates = getAllTemplates.templates;
  var theUserSlug = getAllTemplates.user_slug;
  var templateCards = [];

  //There are templates
  if(allTemplates.length > 0){
    allTemplates.forEach(function(template){
      templateCards.push(templateCard(template, theUserSlug).build());
    });
    return templateCards;
  }
}
Run Code Online (Sandbox Code Playgroud)

该函数在 上调用onTriggerFunction。现在,如果我移到另一张卡上,我想再次回到根目录,但以干净清晰的方式,我使用它,但它不起作用:

  //Move the user to the root card again
  var refreshNav = CardService.newNavigation().popToRoot();
  return CardService.newActionResponseBuilder().setStateChanged(true).setNavigation(refreshNav).build();
Run Code Online (Sandbox Code Playgroud)

简单地说,我想要的是一旦用户点击Refresh按钮,卡片就会刷新/更新自己以再次调用并获取新数据。

google-apps-script gmail-addons

5
推荐指数
2
解决办法
3475
查看次数

标签 统计

gmail-addons ×1

google-apps-script ×1