0

I am new to script and added this script which worked:

function sendEmailAlert() {

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var cellValue = ss.getActiveSheet().getActiveRange().getA1Notation();
    var getRow = ss.getActiveSheet().getActiveRange().getRow();  
    var sheetname = ss.getActiveSheet().getName();

    var user = Session.getActiveUser().getEmail();
    var Toemail = '....email address....';
    var subject = 'New Entry -' + ss.getName();
    var body = 'Your file has a new entry in - ' + sheetname + ' Updated by - ' + user + ' check file- ' + ss.getUrl(); 
    if(Number(ss.getActiveCell().getValue()!=-1.23456789) && getRow ==3) {
        MailApp.sendEmail(Toemail,subject, body);

    }

}; 

However, as I would like to find out which specific cell was changed and the new value, the updated script fails to save so I cannot run it. I guess the mistake is in var body, can anyone help?

function sendEmailAlert() {

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var cellValue = ss.getActiveSheet().getActiveRange().getA1Notation();
    var getRow = ss.getActiveSheet().getActiveRange().getRow();  
    var sheetname = ss.getActiveSheet().getName();

    var user = Session.getActiveUser().getEmail();
    var Toemail = '...email address';
    var subject = 'New Entry -' + ss.getName();
    var body = 'Your file has a new entry in - ' + sheetname + ' Updated by - ' + user + ‘New Value in –‘ + cellValue + ‘= ‘ +ss.getActiveCell().getValue() +
    ' check file- ' + ss.getUrl();

    if(Number(ss.getActiveCell().getValue()!=-1.23456789) && getRow ==3) {
        MailApp.sendEmail(Toemail,subject, body);

    }
}; 
Rubén
  • 34,714
  • 9
  • 70
  • 166
  • I was meant to use Stack Overflow, not sure how got here, first time I use this. Thanks for letting me know –  Jun 07 '19 at 16:45
  • You should specify what language you are using and tag it in the question so it gets in front of the right people. – Christian Gibbons Jun 07 '19 at 19:08

1 Answers1

0

You are right regarding that there is a problem on the var body code line: There are (curly quotes) instead of ' (straight quotes).

Rubén
  • 34,714
  • 9
  • 70
  • 166