OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How To Fix Google Sheets Send Text On Edit bot [duplicate]

  • Thread starter Thread starter Ora Mortis
  • Start date Start date
O

Ora Mortis

Guest
I am currently struggling to write a program that automaticaly sends out an email when the value of a cell changes from 0 to 1, and cant seem to get it to work.

I want it to read the value of a specific cell on edit, see if the cells value has changed, then run an automated email send. I keep getting

TypeError: Cannot read properties of undefined (reading 'range').

Code:
function onEdit (e)
  const specificSheet = "SHEET"   // for example
  const specificCell = "CELL"       // for example

  let sheetCheck = (e.range.getSheet().getName() == specificSheet)
  let cellCheck = (e.range.getA1Notation() == specificCell)

  if (!(sheetCheck && cellCheck)) {
    return
  }
  else {

function sendText() {
    var EmailTo = "EMAIL A";
    var EmailTo = "EMAIL B";
    var subject = "Automated Spreadsheet Access Bot";
    var body = "TEXT";

  MailApp.sendEmail(EmailTo, subject, body);
}
}

<p>I am currently struggling to write a program that automaticaly sends out an email when the value of a cell changes from 0 to 1, and cant seem to get it to work.</p>
<p>I want it to read the value of a specific cell on edit, see if the cells value has changed, then run an automated email send. I keep getting</p>
<blockquote>
<p>TypeError: Cannot read properties of undefined (reading 'range').</p>
</blockquote>
<pre><code>function onEdit (e)
const specificSheet = "SHEET" // for example
const specificCell = "CELL" // for example

let sheetCheck = (e.range.getSheet().getName() == specificSheet)
let cellCheck = (e.range.getA1Notation() == specificCell)

if (!(sheetCheck && cellCheck)) {
return
}
else {

function sendText() {
var EmailTo = "EMAIL A";
var EmailTo = "EMAIL B";
var subject = "Automated Spreadsheet Access Bot";
var body = "TEXT";

MailApp.sendEmail(EmailTo, subject, body);
}
}
</code></pre>
 
Top