Trying to add a 'rolling' note of changes at each cell, including user email, time, old and new values, so I wrote the below script:
/**
* The event handler triggered when editing the spreadsheet.
* @param {Event} e The onEdit event.
*/
function onEdit(e){
// Set a comment on the edited cell to indicate when it was changed.
var range = e.range;
var row = range.getRow();
var column = range.getColumn();
// Get the email address of the person running the script.
var email = Session.getActiveUser().getEmail();
Logger.log("data changed");
range.setNote(range.getNotes().concat('Last modified at: ' + new Date() + ' by: ' + email + ' from: ' + String(e.oldValue) + ' to: ' + range.getValue() + "\n"));
}
I'd the below notes, that are not as I expect:
- User email not displaying at all,
- If I made copy/paste of multiple cells, then old value appear as undefined, and new value for all cells shows only the new value of the first cell.
My sheet can be opened here