I am sharing a sheet with colleagues and want them to enter their name after opening the file for logging purposes. I have no problem running any of my scripts, naturally.
After they open the file, the script does not fire, but I can find the error logs and they say this: You do not have permission to call inputBox at onOpen(Code:12). Why is that? What can I do about it? Moreover, there are instances of the same error message but with a code 13 and 14.
I am not very fluent in Apps Script yet, but is it an authorization, protection issue?
function onOpen() {
//Log the user
var id, usrprops, logname;
id = Browser.inputBox('ID Check', 'Enter your identity (nickname) and press OK', Browser.Buttons.OK);
if (!id) { //if The user did not enter a name
id = Session.getActiveUser().getEmail(); //Get the logged users email address
id = id.slice(0,id.indexOf("@")); //Remove the domain part of email address
}
usrprops = PropertiesService.getUserProperties(); //Get User Properties
usrprops.setProperty('usrname', id); //Save the user name with a key name
return id;
}