0

The idea is that together with the data being saved when clicking on a save button, the user doing that gets its email recorded as a variable, for instance. This is a bounded script. This is how I'm trying it, but it return null

Client-side

const user = google.script.run.withSuccessHandler(function(user) {
  return user;
}).getUser();
console.log('User: ' + user)

Server-side, which works ok

function getUser(){
  const user = Session.getActiveUser().getEmail();
  console.log('Active User: ' + user)
  return user;
}

Appreciate your help!

onit
  • 2,275
  • 11
  • 25
  • In your question, adding more information will help users think of your situation. For example, how is your HTML opened? And, from `This is a standalone based app.`, if you are using Web Apps, can you provide the detailed setting of Web Apps? By the way, although I'm not sure about your current situation, when you use `Session.getEffectiveUser().getEmail()` instead of `Session.getActiveUser().getEmail()`, what result will you obtain? – Tanaike Jul 21 '22 at 02:32

1 Answers1

1

google.script.run() does not return anything. As Tanaike said, its unclear how the scripts are run but assuming its from a bound script you could try this.

google.script.run.withSuccessHandler(function(user) {
  console.log('User: ' + user);
}).getUser();
TheWizEd
  • 7,517
  • 2
  • 11
  • 19
  • Thank you! Despite this one got closed, it did get the user, but after the client-side function had finished run. I'll create a new question on it. PS: It's curious that you help around so much and you got this score...any moderator hunting around? – onit Jul 21 '22 at 13:16