Joshua Joseph
asked on
Google (Get Users Email)
The script run I have will get a timestamp of when a row is edited and puts the user in the comments box at the end of the row of cells. cannot get the script to run and get the email of the current person editing the google sheet. It will only return the email of the Admin/Owner of the script, or it will just retune a blank value.
I have run even combination I can think of using like getEffectiveUser, getActiveUser and so on.
I have run even combination I can think of using like getEffectiveUser, getActiveUser and so on.
function myFunction() {
}
function onEdit(event){
var ss = SpreadsheetApp.getActiveSpreadsheet();
//Script Last Update Timing
var actSht = event.source.getActiveSheet();
var actRng = event.source.getActiveRange();
var activeCell = actSht.getActiveCell();
var row = activeCell.getRow();
var column = activeCell.getColumn();
if(row < 4) return; //If header row then return
var colNums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]; //Coulmns, whose edit is considered
if(colNums.indexOf(column) == -1) return; //If column other than considered then return
var index = actRng.getRowIndex();
var dateCol = actSht.getLastColumn();
var lastCell = actSht.getRange(index,dateCol);
var date = Utilities.formatDate(new Date(), "PST", "MM/dd/yy HH:mm");
// Log the email address of all users who have edit access to a file.
var email = Session.getActiveUser().getEmail();
Logger.log(email);
// Note: Insert the Date when someone update the row in the last coulmn
lastCell.setValue(date).setComment(email);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER