I have a response google spreadsheet connected to a google form.
In the spreadsheet bound script I have and the onOpen like this:
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Configura Gestione NC')
.addItem('Invio eMail', 'openDialog1')
.addToUi();
}
function openDialog1() {
var ui = SpreadsheetApp.getUi();
var response = ui.prompt('Inserisci la mail che riceverà tutte le comunicazioni:', 'Valore attuale: ' + PropertiesService.getScriptProperties().getProperty('emailSupervisore'), ui.ButtonSet.OK_CANCEL);
if (response.getSelectedButton() == ui.Button.OK) {
PropertiesService.getScriptProperties().setProperty('emailSupervisore', response.getResponseText());
}
}
myScript(e){
var SS = SpreadsheetApp.getActiveSpreadsheet();
and do other things
}
I setup an installable trigger on the function myScript(e) that run when the form is submitted because I need to intercept form responses. When I fill and send the form I get the error:
Cannot call SpreadsheetApp.getUi() from this context.
Is onOpen is run even if the trigger is set up on myScript(e)?
In my myScript(e) I don't call SpreadsheetApp.getUi()... is onOpen called automatically even during the script?
Is there a workaround to make works together SS Custom Menus and the myScript function?