I have been banging my head on this for awhile now...my document bound google app script works great when testing local to the document. I tried to test as publish > Test as Add-on with another sheet. Although my onInstall() and onOpen() simple triggers worked fine, my onEdit function did not.
I created this simple code below to find the root cause of my onEdit issue, but even this simple code does not work. I created a new sheet with a bound script. I then tested in another sheet, again the onInstall() and onOpen() worked fine, the opOpen menu even called my on Edit function, but when editing a cell nothing happens. Any help is appreciated, I would like to get this to work with simple triggers not installable triggers, as this seems like a really simple use case.
function onOpen(e) {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Test Menu')
.addItem('Hello', 'onEdit')
.addToUi();
}
function onInstall(e) {
onOpen(e);
}
function onEdit(e) {
Logger.log('ran onedit!');
SpreadsheetApp.getUi().alert('Hello');
}
The script must be bound to a Google Sheets, Docs, or Forms file.
Which is why it works when Testing as an Add-on using the same spreadsheet it is bound to, but not when using a different spreadsheet. In which, an Installable Trigger would fix the issue - even if it seems like overkill. There is an Open Issue in the bug tracker you can follow. – random-parts