0

Below is the code I am using. Even when I specify the sheet/tab name, I still get the error. If I remove that line, the following line will error with the same message "not a function. I am trying to set it up so I will get an email once a cell in a column changes.

Thank you.

function sendNotification() {
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  var sheet = ss.getSheetByName();
  var cell = ss.getActiveCell().getA1Notation();
  var row = sheet.getActiveRange().getRow();
  var cellvalue = ss.getActiveCell().getValue().toString();
  var recipients = "myemail@me.com";
  var message = '';
  if(cell.indexOf('G')!=-1){ 
    message = sheet.getRange('A'+ sheet.getActiveCell().getRowIndex()).getValue()
   }
  var subject = 'Other'+ sheet.getRange('A'+ sheet.getActiveCell().getRowIndex()).getValue() + 

' has been detected';
      var body = sheet.getName() + ' has been updated. Visit ' + ss.getUrl() + ' to view the changes on row: «' + row + '». New comment: «' + cellvalue + '». For message: «' + message + '»';
      MailApp.sendEmail(recipients, subject, body);
    };
Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    Try to remove the `.getSheets()` from the second row. And specify a name of the sheet in `.getSheetByName()` inside the brackets – Yuri Khristich Sep 16 '22 at 12:21
  • Welcome to [so]. Please start by reading https://developers.google.com/apps-script/guides/sheets. Tl;Dr To effectively use Google Apps Script you need to know the pretty basics of JavaScript, more specifically understand objects, properties and methods, and to use it with Google Sheets also need to understand Arrays. – Rubén Sep 16 '22 at 13:32

0 Answers0