I just want to tweak some menus after performing some actions on this HTML modal, using google.script.run
API
my gasp code is something essentially like this:
function some() {
const output = HtmlService.createHtmlOutput(someHTML).setWidth(600).setHeight(425);
SpreadsheetApp.getUi().showModalDialog(output, 'some title')
}
function tweakMenu(){
const ui = SpreadsheetApp.getUi()
const mainMenu = ui
.createMenu('Mainn')
.addItem('So nice', 'function').addToUi()
return 'some thing'
}
Then I have the following chunk along with the html loaded by HTMLService:
var selfClose = (e) => {
console.log(e) // does not log 'some thing'
google.script.host.close();
}
$('#done-button').on('click', () => {
google.script.run
.withSuccessHandler(selfClose)
.withFailureHandler(selfClose)
.tweakMenu();
})
The function that tweaks the menu works well when called directly, however, when I call it by that JS click handler it does not return any data, either by success or failure handler, but the modal itself closes.
This is a google sheets public add-on but I'm currently testing this code in a staging context.
I have a feeling that some GAS APIs aren't available in this way, I've also tried to use URLFetchApp in the past and it didn't work either.
Is there any way to accomplish this? The bottomline is: I'm trying to tweak some stuff after the user upgrades their plan.