I've run into an issue with the onEdit
simple trigger using the Google Apps Script in a Google Doc Spreadsheet.
The range
in the event object
passed to onEdit
always maps back to cell A1
.
There are a few other issues I'm encountering with onEdit
and the event object
but this is a very narrow and specific example which is hopefully easy to ask a question about.
My Repro Steps:
- Login to google docs
- Create new spreadsheet
Tools->Script Editor
(this will open in a new tab)- Replace contents of Code.gs with the following (C&P from [https://developers.google.com/apps-script/understanding_events#eventsDetails])
function onEdit(e) {
e.range.setComment("Edited at: " + new Date().toTimeString());
} - Save changes to Code.gs
- Return to the spreadsheet tab
- Enter the number 7 into cell
C3
then hit enter Note: What's entered doesn't appear to matter, just need to trigger theonEdit
event - Wait for spreadsheet to save change to server
- Cell
A1
is updated with a comment that says,Edited at: [current time]
The expected behavior is that the comment is added to cell C3. As per the documentation stating;
[The example in step 4] is a function that is triggered when a Spreadsheet is edited. It uses the e parameter to access the cell that was edited and add a timestamp.
Having this basic example from documentation failing leaves me at a loss of what I can be doing incorrectly or how else to approach finding a solution.