3

Is it possible with Google Apps Script to either

A. Have a custom menu show up only for specific users? or B. Only allow specific users to click on a menu item.

I'd like to use the get active user command and try to bounce that off of a specific cell in another Google sheet in which our secretary maintains of about 5 administrators. Pull the email address from the sheet make it a variable called principal or directorOfTechnology etc. and have some kind of if statement so that either a menu only shows up for that person or an if statement so that if they are the correct person it does what I have and if not they get a message or something saying You are not able to click on this button etc.

If this is possible how would I go about writing this code? I am still in the learning stages and am not sure how to get this started and if this is even possible.

  • This is only possible if you are using a Google apps business or education account in a domain, not in ordinary Gmail account because it won't let you know the user identity in a triggered function. – Serge insas Apr 18 '16 at 15:31
  • We are using an education account. How would I make this happen? – Bryan Erskine Feb 08 '17 at 22:02

1 Answers1

0

Doing this in the way you describe runs up against the fact that onOpen() runs in 'limited' authMode: you won't be able to read from the spreadsheet until the auth cycle is complete & your script gets to full authMode. (documentation)

Here are 2 possible work-arounds:

  1. You can specify a list of authorised accounts in your script & check against them. This makes it difficult for a third party to manage the ACL as they have to modify the script directly.

  2. You can deploy the script as a Sheets add-on & make it accessible only to members of a Google Group. e.g.enter image description here You can then devolve management of the access group to a third party.

Dean Ransevycz
  • 933
  • 8
  • 22