-2
function onEdit(e) 
{
  var approval = e.range.getvalue();
  
  if(approval == "Approved")
  {
  
    e.source.getActiveSheet()
  //.getRange(e.range.rowStart, columnToStamp)
  //.setValue(new Date());
    
    MailApp.sendEmail("ishwarisaskar@gmail.com", "Approved", "In If loop");
  
  }else
  {
  
    MailApp.sendEmail("ishwarisaskar@gmail.com", "Approved", "In Else loop");
    return;
    
  }
  
}

Facing error I want Sheet edited time in Column what should I do ?

player0
  • 124,011
  • 12
  • 67
  • 124

1 Answers1

2

First of all, getvalue() should be getValue(), therefore:

var approval = e.range.getValue();

you are actually checking for every cell that was edited whether it contains 'Approved' or not.

Alternatively, if you want, you can be more specific on how to request a value from a particular sheet. Here is an example how you could request cell A1 from the sheet with the name Sheetname or the active sheet.

You could request approval like that :

var approval =e.source.getSheetByName('Sheetname').getRange('A1').getValue();

or

var approval = e.source.getActiveSheet().getRange('A1').getValue();

In the second case, you are only checking for cell A1, while in the first case you are checking for every cell that is edited whether it contains 'Approved' or not.

Marios
  • 26,333
  • 8
  • 32
  • 52