I have a google sheet that for the past 18 months has worked fine, inputting a username in a particular row/column when a corresponding cell is edited by using something basically like:
function onEdit(e) {
(Session.getActiveUser().getEmail());
....
}
Lately, this has stopped working, probably as we are not on a GSuite service (although I'm wondering why it ever worked now).
I've tried disabling the V8 runtime, tried an installable onEdit trigger, tried to use Drive API scripts to get the username (adding Drive API in "Advanced Google Services"), some old workarounds (that no longer work), revoked permissions and allowed again, but no luck.
It seems a bit odd that it was working (Stopped maybe start of Oct 2021), and that I can click a cell and check the edit history, but can't get a username data written into a cell for security reasons.
There are several older posts on this but no current solutions, so apologies for digging this up again, but I'm wondering if there is solution?
Update following Kos' help: (Re)Adding a trigger seems to fix the permissions issue, provided that it is Runtime V8 AND the trigger is added per each user, the email address is then correctly logged. However, as there are now several onEdit triggers they each conflict and this email address entry is quickly deleted. The Edit History of the cell shows the "other" users delete the email address immediately.
Another Update: I got around this conflict by adding a Lock on the contents of the onEdit, see https://stackoverflow.com/a/68191989/2441916
function onEdit(e) {
var lock = LockService.getDocumentLock();
lock.waitLock(20000);
// DO SOMETHING
SpreadsheetApp.flush();
lock.releaseLock();
}
Key takeaways:
- Each user must have an onEdit trigger installed (and authorised). (if non-business suite)
- Must be Runtime V8
- Content Lock on onEdit required (see linked post)