1

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;
 }
Rubén
  • 34,714
  • 9
  • 70
  • 166
Norbert
  • 45
  • 7
  • Can you share your actual script code here ? – Umair Mohammad Feb 06 '18 at 14:07
  • didnt think it would be of any use *adding now – Norbert Feb 06 '18 at 14:11
  • Short answer: yes, this is an authorization issue. Every trigger function that runs when certain conditions are met, such as onOpen(), onEdit(), etc, must be authorized by the end user. They must either run the function manually from the script editor and grant all permissions or install your script as a sheets add-on with proper authorization scopes declared in the add-on manifest. More details https://stackoverflow.com/questions/48610745/onedit-trigger-doesnt-catch-current-user/48611026#48611026 – Anton Dementiev Feb 06 '18 at 15:02
  • Does this answer your question? [Execution failed: You do not have permission to call getProjectTriggers](https://stackoverflow.com/questions/21219031/execution-failed-you-do-not-have-permission-to-call-getprojecttriggers) – Rubén Jul 23 '20 at 23:21

0 Answers0