'onEdit() not called when i do test deployment
i am creating google sheets addon, according to google docs
https://developers.google.com/apps-script/guides/triggers#getting_started
onEdit is a simple trigger which doesnt need to be installed
this is my code.gs
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.createMenu('Custom Menu')
.addItem('Show alert', 'showAlert')
.addToUi();
}
function showAlert() {
}
function onEdit() {
console.log("on edit called")
}
and clicked on test deployment and opened the spreadsheet which i have full access to
however onEdit doesnt seem to be called when i edit the values in spreadsheet ( doesnt show on execution logs too), what should be done for simple triggers to work ?
Solution 1:[1]
Test deployment doesn't help to test Google Workspace Editor Add-ons, they are intended to be used with Google Workspace Add-ons that are a different kind of add-ons.
To test an Editor add-on you might use the now called "Classic Editor" and use Run > Test as add-on. For details see https://developers.google.com/apps-script/add-ons/how-tos/testing-editor-addons.
NOTE: I have not found helpful Run > Test as add-on. I prefer to use a bounded script to do some of the early tests on the bounded spreadsheet, then publish the editor add-on for internal use only (this requires a Google Workspace account) for doing other tests when they are really needed.
It's worthy to mention that Editor add-ons might be installed, enabled or installed and enabled.
The installation is done once by user.
The add-on should be enabled on each spreadsheet (or document, or form, or presentation) before they can be used. In order to be able to enable the add-on there should be a custom menu at least with one option.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |