The solution is sketched in this post, but it seems key steps are not identified. This code works fine if in GAS bound to the spreadsheet:
function onEdit(e) {
var sheet = e.source.getActiveSheet();
var activeCell = sheet.getActiveCell();
var row = activeCell.getRow();
if(row != 1) {
sheet.getRange(row, 4).setValue(new Date().toISOString())
}
}
In the owner account's G-drive, I created a script as follows:
function onEdit(e) {
var ss = SpreadsheetApp.OpenFileById("[spreadsheet ID]");
var sheet = ss.getActiveSheet();
var activeCell = sheet.getActiveCell();
var row = activeCell.getRow();
if(row != 1) {
sheet.getRange(row, 4).setValue(new Date().toISOString())
}
}
But this script does not set the date value in the active sheet when an edit is made. I deployed this detached script (as webapp) and gave it permission to access the spreadsheet. But I suspect there are other steps or I have not properly deployed the script so that it can respond to edits in the active sheet of the spreadsheet.