0

I am trying to create a notification script in Google Sheets whereby when a value in a range of cells change and meets a conditional (ie. when any of the cells in the range go to 0) I want it to send me a notification that it has updated to 0 along with the contents of that row. How can I do this in Google Sheets?

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    If the initial cause of the change is a manual edit, then you can use an installable "On Edit" trigger. From the code editor, choose "Help", and then "Documentation". Then search with the text: "trigger inst" Read the documentation. – Alan Wells Oct 02 '16 at 13:02

1 Answers1

0

In appscript, you can store all the spreadsheet cells of a particular tab in 2D array format like this:

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('YOURSHEET');
var data = sheet.getDataRange().getValues();

So now, you can get any cell's value, e.g. using data[2][3] etc... Also, using 'sheet' var declared above, you can do lot of sheet operations. So, to send the entire contents of your row, you can use the same data var. To check if the value has become zero continuously, you can set trigger of every minute or you can set From Spreadsheet->onEdit trigger

Now, to send an email, you can use following:

var emailAddress = "abc.def@ghi.jkl";  
    var message = "Some message"; //In your case, values of your row   
    var subject = "Something matched your condition";
    MailApp.sendEmail(emailAddress, subject, message);
Shyam Kansagra
  • 892
  • 12
  • 24