0
votes

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:

  1. Login to google docs
  2. Create new spreadsheet
  3. Tools->Script Editor (this will open in a new tab)
  4. 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());
    }
  5. Save changes to Code.gs
  6. Return to the spreadsheet tab
  7. Enter the number 7 into cell C3 then hit enter Note: What's entered doesn't appear to matter, just need to trigger the onEdit event
  8. Wait for spreadsheet to save change to server
  9. 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.

1

1 Answers

1
votes

With the release of new sheets, a few of the Google Apps Script features where broken, in particular the one that you mention.

You will find documentation on this and other current issues here: https://developers.google.com/apps-script/migration/sheets#onedit_triggers

Be sure that the team is working hard to resolve this and you can probably have a shot as asking a question or two on the subject in wednesday Google Apps Unscripted : https://plus.google.com/u/0/116174873209306927411/posts/MbXQhKusUZ3?cfem=1