Not sure if you have solved all your issues or not, but I figured I would share my solution.
Our team has multiple spreadsheets that record the last user to edit a row and the date of the edit in the last two columns of that row.
First I have a masterOnEdit(e) function that looks like this:
function masterOnEdit(e) {
// Get active spreadsheet and row information
var sheet = SpreadsheetApp.getActiveSheet();
var row = e.source.getActiveCell().getRow();
var col = e.source.getActiveCell().getColumn();
// Set last updated and user cells if not editing those cells
if (row > 3 && col < (sheet.getLastColumn()-2)) {
setLastUpdated(sheet);
}
}
This function ignores the first three rows (header rows for me) and ignores edits to the last two columns (in case you want to manually add a user/date).
This function also calls a function called setLastUpdated(sheet). Note that I pass the sheet variable to this sub-function to limit Google API calls. The real editing takes place here:
function setLastUpdated(sheet){
var row = sheet.getActiveCell().getRow();
var email = Session.getActiveUser().getEmail();
var user = parseUser(email);
var userCell = sheet.getRange(row, sheet.getLastColumn()-1)
userCell.setValue(user.name);
userCell.setBackground(user.color);
var date = Utilities.formatDate(new Date(), "GMT-5", "h:mm a M/d/yy");
sheet.getRange(row, sheet.getLastColumn()).setValue(date);
}
One more sub function in this code block parses out the username. This function takes in the e-mail returned by google and parses it to our team names using regex. This also allows me to set the color of the user cell depending on which team member made the edit.
function parseUser(email) {
var user = {name: email, color:'#FFFFFF'}
if (/peter/.test(email)){
user.name = 'Peter';
user.color = '#4585F1';
}
}
Hope this helps. I built this based on some of the most complete examples I found online. Really helps our team track who is working on our spreadsheet workflows.