I am developing spreadsheet tools from a library, through an HTML template, but the server functions do not work.
gs simplified code (the functions are longer):
function Cancel_Version(){
return Action_Box("¡HEY!","You're to cancel active edition.\n\n Sure?","Cancel_Version2()");
}
function Action_Box(TITLE,MESSAGE,FUNCTION){
var html = HtmlService.createTemplateFromFile('ACTION_BOX');
html.data = MESSAGE;
html.action = FUNCTION;
SpreadsheetApp.getUi().showModalDialog(html.evaluate().setHeight(200),TITLE);
}
function Cancel_Version2(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.deleteActiveSheet();
}
HTML code:
<!DOCTYPE html>
<?!= include('CSS'); ?>
<form style="font-size: 22px; font-family: 'calibri'; ">
<?!= data; ?>
<br>
<br>
<input type="button" value="ACCEPT" onclick="<?!= action; ?>; google.script.host.close();"/>
<input type="button" value="CANCEL" onclick="google.script.host.close();"/>
</form>
Why the code action does not work??. Even I have substituted <?!= action; ?>
with Cancel_Version2()
but still does not work. On the other hand, if I call directly the function from a onOpen menu, it works.
What am I missing???