0
votes

I am trying to send auto generated mail based on text value of Google sheet. In My Sheet column, F is the row with the status " Approved' Or "Rejected"

If Status is " Approved' mail should generate

I have created the code, however, i think need small modifications

    function myNotification() {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var ss_sheet = ss.getSheetByName('Form Responses 1')
var ss_sheet_datarange = ss.getDataRange().getValues();
var ss_sheet_lastrow = ss_sheet.getLastRow()
for (var i = 5; i < ss_sheet_lastrow; i++)
var approvalstatus = ss_sheet_datarange[5][i] // column F is the row with the status in
var approval_status = 5;
  
if (approval_status == 'Approved') {
var email = Session.getUser().getEmail();
  
  MailApp.sendEmail(email, "Test", "Test");
}
1

1 Answers

0
votes

Change
if (approval_status == 'Approved') {

For if (approvalstatus == 'Approved') {

You have two variables very similar, but in your code, approval_status will ALWAYS be 5