UncleZeiv
UncleZeiv

Reputation: 18488

How can I access the name of the user running a script embedded in a shared spreadsheet?

I have a Google Spreadsheet containing a script that I wrote. The script updates a per-person sheet named after the logged in user, or creates a new one if it's not there yet.

I shared it in "can edit" mode with other people, expecting the code accessing the user name to work as it did in my case, but apparently it doesn't.

Google Apps Script seems to contain three ways to get the name of the current user:

and all of them return the empty string when I'm not the user running the script.

(Btw I'm having a hard time to tell the difference between them...)

Considering that I'm sharing this spreadsheet in read/write mode, I would be a bit surprised if this was an intended security method... it's not like I don't know the emails of the people accessing the spreadsheet I've explicitly shared with them... Plus, Google is asking for permission anyway, couldn't it ask for permission to access the user name as well??

Is there a way around this?

Upvotes: 1

Views: 1915

Answers (1)

Henrique G. Abreu
Henrique G. Abreu

Reputation: 17752

Is there a way around this?

These methods only work if you're using a Google Apps account and you're on the same domain as the user. If not, then there's no way to get the user id. AFAIK Google removed this feature completely for regular accounts. You may try to argue with them opening an issue here.

Upvotes: 3

Related Questions