I wrote a script that sends an email immediately when a cell is updated in the GOOGLE SEETS sheet with the contents of the cell When I run it, it throws an error and it says:
TypeError: Cannot read properties of undefined (reading 'source') onEdit @ קוד.gs:3
I have a GOOGLE SEETS sheet that receives data from GOOGLE FORMS. I want as soon as the sheet is updated to receive an email with the received data. This is what I wrote:
`
function onEdit(e) {
// מחזירה את הגיליון הפעיל
var sheet = e.source.getActiveSheet();
// מחזירה את התא הפעיל
var cell = e.source.getActiveCell();
// מחזירה את השורה שבה נמצא התא הפעיל
var row = cell.getRow();
// מחזירה טווח של תאים מתוך הגיליון הפעיל, מתחיל מהשורה הראשונה והעמודה הראשונה ומכיל את השורה המעודכנת
var range = sheet.getRange(row, 1, 1, sheet.getLastColumn());
// מחזירה מערך של הערכים שבתאים המצויים בטווח שנבחר
var values = range.getValues();
// מאחדת את כל האיברים שבמערך לתוך מחרוזת אחת, בעזרת המפריד ","
var message = values.join(", ");
// שולחת מייל לכתובת EXAMPLE@gmail.com עם נושא "עדכון בגיליון" וגוף ההודעה הוא השורה המעודכנת
MailApp.sendEmail("EXAMPLE@gmail.com", "עדכון בגיליון", message);
}
`
This is the error I get:
TypeError: Cannot read properties of undefined (reading 'source') onEdit @ קוד.gs:3
[It is possible that the language is a bit sloppy, this is because it is a translation from Hebrew to English, using Google Translate]