ss.getSheetByName() not a function errlr

Viewed 24

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);
    };
0 Answers
Related