应用程序脚本附加卡服务刷新问题

发布于 2025-01-20 03:47:34 字数 1300 浏览 3 评论 0原文

我使用卡服务创建了附加组件。 我想要的只是运行函数refresh()以清除电子表格中的数据,并且在我按下注销按钮后,应刷新。

我使用以下代码尝试运行函数refresh(),我的附加组件应重新加载以显示一些详细信息。重定向URL(cardFooter1button1openlink1)工作正常,但是它没有调用函数refresh

function refresh(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var clear = sheet.getSheetByName('OfficeUsers'); 
var range = clear.getRange('D3:I').clearContent()
}


function newdemo(){
 var cardFooter1Button1Action1 = CardService.newAction()
        .setFunctionName('refresh');

    var cardFooter1Button1OpenLink1 = CardService.newOpenLink()
        .setUrl('www.office.com/logout')
        .setOnClose(CardService.OnClose.RELOAD_ADD_ON);

    var cardFooter1Button1 = CardService.newTextButton()
        .setText('Logout')
        .setOnClickAction(cardFooter1Button1Action1)
        .setOpenLink(cardFooter1Button1OpenLink1);

    var cardFooter1 = CardService.newFixedFooter()
        .setPrimaryButton(cardFooter1Button1);

    var cardSection1 = CardService.newCardSection();


    var card = CardService.newCardBuilder()
        .setFixedFooter(cardFooter1)
        .addSection(cardSection1)
        .build();
  return card;

}

请帮助我,当我按注销时,它正在重定向到URL,当我关闭弹出弹出时,正如我所期望的那样,它也正在刷新附加组件,但是功能refresh()没有调用。

I created add-ons with the card service.
All I wanted is to run the function refresh() to clear data in Spreadsheet and add-on should refresh once I press Logout Button.

I use the below code to try running the function refresh() and my Add-ons should reload to display some details. Redirect URL (cardFooter1Button1OpenLink1) is working fine, but it's not calling the function refresh

function refresh(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var clear = sheet.getSheetByName('OfficeUsers'); 
var range = clear.getRange('D3:I').clearContent()
}


function newdemo(){
 var cardFooter1Button1Action1 = CardService.newAction()
        .setFunctionName('refresh');

    var cardFooter1Button1OpenLink1 = CardService.newOpenLink()
        .setUrl('www.office.com/logout')
        .setOnClose(CardService.OnClose.RELOAD_ADD_ON);

    var cardFooter1Button1 = CardService.newTextButton()
        .setText('Logout')
        .setOnClickAction(cardFooter1Button1Action1)
        .setOpenLink(cardFooter1Button1OpenLink1);

    var cardFooter1 = CardService.newFixedFooter()
        .setPrimaryButton(cardFooter1Button1);

    var cardSection1 = CardService.newCardSection();


    var card = CardService.newCardBuilder()
        .setFixedFooter(cardFooter1)
        .addSection(cardSection1)
        .build();
  return card;

}

Please help me, When I press Logout, It's redirecting to URL and when I close the pop up, it's refreshing the add-on also as I expected but function refresh() is not calling.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文