0

I have created an add-on for Google Sheets.

var ss = SpreadsheetApp.getActive();
ScriptApp.newTrigger('checksheetchange')
  .forSpreadsheet(ss)
  .onChange()
  .create()

function checksheetchange(){
var card = CardService.newCardBuilder();
var cardHeader = CardService.newCardHeader();
var response = JSON.parse(response.getContentText())
cardHeader.setTitle(
  '<font color="#1257e0">File upload error!</font>'
).setSubtitle(response.message);
card.setHeader(cardHeader);
return card.build();}

The requirement is: when a new sheet is added or removed the add-on has to be refreshed with the card in checksheetchange accordingly.

Even through the control comes to the function "checksheetchange", when a sheet is added or removed, there is no change in the card displayed in the add-on.

How can I refresh the add-on from the function "checksheetchange"?

Divya Dev
  • 125
  • 9
  • Whenever you create a new trigger you should check to make that there isn't already a trigger defined for that function. Multiple trigger function can be difficult to debug. – Cooper Apr 17 '21 at 16:28
  • What I do is delete all existing triggers. But, the control is not passing from the trigger to the add-on. The cards are not refreshing. – Divya Dev Apr 18 '21 at 18:44
  • Why delete all of the triggers when you don't have to. – Cooper Apr 18 '21 at 18:57
  • Oh Ok. But, how do I refresh cards with a trigger? – Divya Dev Apr 18 '21 at 19:02
  • What is this line supposed to do?`var response = JSON.parse(response.getContentText())` response is not defined? – Cooper Apr 18 '21 at 19:33
  • @Cooper In fact, the function can be as simple as: function checksheetchange(){ var card = CardService.newCardBuilder(); var cardHeader = CardService.newCardHeader(); cardHeader.setTitle( 'File upload error!' ); card.setHeader(cardHeader); return card.build();} – Divya Dev Apr 18 '21 at 21:31
  • Well I'm just pointing out that you're declaring a variable and using the undeclared variable inside the assignment function. So that doesn't make much sense. If you going to post a lot of code please post it in your question so that it's easier to read. – Cooper Apr 18 '21 at 21:36
  • [This may be helpful](https://stackoverflow.com/questions/62594317/) – Rafa Guillermo Apr 19 '21 at 11:06

0 Answers0