I have a script for GOogle Sheets that works almost perfectly.I just need one addition: To add the logged in user to the cell. I have a sheet called "GMB Descriptions" When a user enters information in any cell row in column 4, it shows the date & time in column 5 of the same row. No problem. The issue is I want it to show the logged in user in that cell as well Currently (script below) shows: MM/dd/yyyy - hh:mm a I want it to show: MM/dd/yyyy - hh:mm a - LoggedIn User I understand it would use the user email who made the change to that row.
Summary: How do I add the code to the following script to also show the user who made that edit?
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "GMB Descriptions" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 4 ) { //checks the column
var nextCell = r.offset(0, 1);
if( nextCell.getValue() === '' ) //is empty?
var time = new Date();
time = Utilities.formatDate(time, "GMT-8", "MM/dd/yy - h:mm a");
nextCell.setValue(time);
};
};
}
e.user.getEmail()
is used. The problem is that it has limited functionality (security reason). For example it will NOT work if the Sheet is shared by hyperlink for editing. – Александр Ермолин