0

So my code suppose to make me a tracking sheet of edits on the main sheet but when its gets the email it gives an empty email unless its my main email then its works for some reason here is the main function. and my friend from his pc it didnt even got "" the script didnt run so irdk the problems. btw i am new to this so dont make fun of me please.

function onEdit(e) { // Check if the event object is defined if (!e || !e.source) { // If the event object is not defined or does not have 'source' property, exit the function return; } var ss = e.source; // Get the active spreadsheet var trackingSheetUrl = "https://docs.google.com/spreadsheets/d/1VR1wc5xGtAB6dYmQCf9ChphwfHoOYI-7qKEjJEs42Lo/edit#gid=1175584031"; // Put the URL of your tracking sheet here var trackingSpreadsheet = SpreadsheetApp.openByUrl(trackingSheetUrl); var trackingSheet = trackingSpreadsheet.getSheets()[1]; // Assuming the tracking sheet is the first sheet var user = Session.getActiveUser().getEmail(); // Get the email of the user who made the change if (user == ""){ user = "error"; } var userLocation = searchDataColumnWithUser(trackingSheetUrl, user); if (userLocation) { // User found, increment the value var currentValue = userLocation.getValue(); userLocation.setValue(currentValue + 1); } else { // User not found, create new row var lastUserRow = trackingSheet.getLastRow(); var newUserRow = lastUserRow + 1; trackingSheet.getRange(newUserRow, 1).setValue(user); // Set username trackingSheet.getRange(newUserRow, 2).setValue(1); // Set initial value as 1 trackingSheet.getRange(newUserRow, 2).setValue(1); // Set initial value as 1 } } 

I suppose to get the email and update the sheet.

2
  • Hi. As a new user, welcome. Sometimes we need to ask questions, request more information, and refer to the Help Tour in order to focus on how a question could be enhanced by providing more/different information. Admittedly these can sometimes be terse. But it applies to everyone, even very experienced users. I would be both disappointed and surprised if anyone were to make fun of you Commented Feb 17, 2024 at 0:33
  • Does this answer your question? Unable to get Active user's email Commented Feb 17, 2024 at 4:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.