I have a script that should change the background color of a cell depending on which user inputs data. It seems the script does not recognize other users but me (the sheet owner), so when someone else inputs data the cell changes color but only to the one designated to my user.
I've tried a switch statement but nothing happened, so I used if and else if statements and at least got the cells to change colors. I program another cell to show the user name to check who is editing data, but only my username appears, other just don't show up.
function onEdit(e){ var s = SpreadsheetApp.getActiveSheet(); var cell = s.getActiveCell(); var user = Session.getActiveUser().getEmail(); if( s.getName() == "Sheet1" ) { if(cell.getColumn() == 2 ) { var colorCell = cell.offset(0,-1); var conCell = cell.offset(0,13); //Confirmation cell to see the user name conCell.setValue(user); var dateCell = cell.offset(0, 12); //this bit is to register the date of the edit if( dateCell.getValue() === '' ){ dateCell.setValue(new Date());} if (user = "[email protected]"){//only this user name seems to be recognized colorCell.setBackground('#dbbf94'); } else if (user = "[email protected]"){ colorCell.setBackground('#94dbab'); } else if (user = "[email protected]"){ colorCell.setBackground('#cf9ce5'); } } } } I want the background color to be specific for each user