1 year ago

#388266

test-img

Moses01

Apps Script Add-on Card Service Refresh Issue

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.

google-apps-script

web-applications

google-workspace-add-ons

0 Answers

Your Answer

Accepted video resources