M
M
Mirtopir2020-05-19 01:19:41
Google Sheets
Mirtopir, 2020-05-19 01:19:41

How to get an email that changes a google spreadsheet?

I would like to indicate the author of the changes in the column after the change is made.
There is an onEdit trigger, but how can I find out the username/soap of the person who makes the edit?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2020-05-19
@ProgrammerForever

For simple triggers like onEdit and custom functions , the user object is not available , you can see this if you make the following code:

function onEdit(e) {
  SpreadsheetApp.getActiveRange().setValue(Utilities.formatString("email: %s",e.user.getEmail() ));
}

But no one forbids to make another function and assign it a trigger "On change" ( Edit - Triggers of the current project - Adding a trigger - onEditTrigger - Main deployment - From table - On editing - Save ):
function onEditTrigger(event) {
        var userEmail = event.user.getEmail();                  //Email пользователя
  //Что-то делаем...
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question