I work on a Google Drive with other people and we have multiple google sheets. I defined a "OnEdit" function to get the name of the people editing a specific column in a sheet, so that I can send to discord the following message "User X has updated the sheet Y."
But I can't get the name of the current user (except me). I use the following script:
function getCurrentUserEmail() { var protection = SpreadsheetApp.getActive().getRange('A1').protect(); protection.removeEditors(protection.getEditors()); var editors = protection.getEditors(); if (editors.length === 2) { var owner = SpreadsheetApp.getActive().getOwner(); editors.splice(editors.indexOf(owner), 1); } var userEmail = editors[0]; protection.remove(); return userEmail;} I believe the user editing the script doesn't have the authority to execute "removeEditors"
The classic "Session.getActiveUser()" also doesn't work for anyone but me (it returns a blank)
It is starting to become frustrating; if it is a problem of access rights, what can I do?