Working on a sheet that when the user edits a cell (example C3), it will insert his/her email (name). Have a scrip that does work for only one column ("C"), but when moved to another sheet or column ("5 or E") it gives “Error – you do not have permission to call getActiveUser (line 41)".
Because it does work once, not sure what I am missing or why the same script wont work at all on another sheet. Thanks for any assistance.
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
var email = Session.getActiveUser().getEmail();
Logger.log(email);
if( r.getColumn() == 3 ) { //checks the C column
var nextCell = r.offset(0, 1);
nextCell.setValue(email);
if( r.getColumn() == 5 ) { //checks the E column
var nextCell = r.offset(0, 1);
if( nextCell.getValue() !== '' ) //is empty?
nextCell.setValue(email);
}
}
}