App Current User within my google sheet

Hi all,

I’m trying to get the current app user within my google sheet, but I’m not being able to achieve it.

I’ve set a custom trigger in the google sheet (onchange) that fires the following script.

function myFunctionSetCurrentUser() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName('Hoja 1');

  // GET EMAIL ADDRESS OF ACTIVE USER
  var email = Session.getActiveUser().getEmail();
  Logger.log(email);

  //SET CELL A1 TO EMAIL ADDRESS OF ACTIVE USER
  sheet.getRange(1,1).setValue(email);
}

This script gets the current user name and sets its value in A1, but I’ve found out that this user is not the app user but always the google sheet owner / app creator. Does anybody know how can I get the app signed in user?

Thanks for your time mates!

What are you trying to do? Google sheets has no idea who the current active user in that app is. Especially if you have hundreds of concurrent users, how would you display that in one sheet cell? It’s only a database to store data.

If you are trying to display a user’s name or email on a page, you will have to use per user filtering on a detail page. Filter by signed in user to match the signed in user to a row that contains their email. Then you can display their email, or add a column that contains their name.