Reputation: 480
I am trying to get the active user email so I can apply rules to each email. As I am doing this as an web app I am unsure how to get that info and paste it into a html page. I tried with this code and it works, but not as I want:
var app = UiApp.createApplication();
app.add(app.createLabel('Effective User: ' + Session.getEffectiveUser().getUserLoginId()));
return app;}
As I am unsure how to get it inside a HTML file i am asking for your help.
Upvotes: 1
Views: 1114
Reputation: 46794
In your client side javaScript use a function like this to assign a value to the user
variable ( in this case I declare it outside of the function to make it global):
var user;
google.script.run.withSuccessHandler(getUserEmail).getUser();
function getUserEmail(userMail){
user = userMail;
}
and in your .gs file (server side code) write a simple function like below that will send the user email :
function getUser(){
user = Session.getActiveUser().getEmail();
return user;
}
Upvotes: 1