Karl_S
Karl_S

Reputation: 3574

ReferenceError using Session.getActiveUser() in Google Apps Script

I have a Google Apps Script and am trying to use Session.getActiveUser() but get an "Uncaught ReferenceError: Session is not defined" error in the Developer Tools view. This is a Published Web App running as the User. It is happening when testing with the latest code. It is in a Google Apps for Education domain.

This may or may not be related: I had also tried to use Utilities.sleep() which gave me the same error for Utilities. I worked around this issue.

Is there an Advanced Google Service I need to turn on or some other setting I need to make? My ultimate goal is to be able to add the name of the person running the script to a cell in the spreadsheet. Once I can retrieve their name I have the rest.

Regards, Karl

Upvotes: 0

Views: 989

Answers (1)

Zig Mandel
Zig Mandel

Reputation: 19864

you are calling the appscript api from the HtmlService clientside javascript. no apps script apis can get called client-side, must be in your .gs or in templated html.

To call a server function from the client side, see https://developers.google.com/apps-script/guides/html/reference/run

Upvotes: 1

Related Questions