1

If would like to receive an email notification if a new row is added to a specific tab in a Google Sheets.

The default notification rule settings are too limited and the Google Sheets Add-on Store does not provide any suitable add-on script:

enter image description here

How to send such notifications with a Google Apps script?

  • Did you already googled to find the script you are looking for? Do you know how to write a script? What did you already tried? – Rubén Jan 18 '16 at 15:21
  • Thank you for your comment. Yes, I have searched the Google Sheets Add-on Store but could not find any equivalent. Unfortunately, my knowledge is too limited to write such a script myself. – orschiro Jan 18 '16 at 16:57
  • Do you know how to write a script to send and email? – Rubén Jan 18 '16 at 17:09
  • Dear @Rubén, I learned how to write a script that sends an email notification from the answer below. – orschiro Jan 19 '16 at 8:56
  • 1
    That's great! For your next question, I think that the following will be helpful: How do I write a great question? – Rubén Jan 19 '16 at 17:54
2

The event object helps here, specifically its changeType property, which tells the script what kind of change happened. If this change is INSERT_ROW, and the name of sheet matches the one you want, then an email is sent using MailApp.

function notify(e) {
  var sheet = SpreadsheetApp.getActiveSheet();
  if (sheet.getName() == 'Tracked Sheet' && e.changeType == 'INSERT_ROW') {
    MailApp.sendEmail('myemail@gmail.com', 'Row Added', 'A row was added to your sheet.');
  }
}

To use this, add a trigger (Resources > Current project's triggers) with the properties "From spreadsheet | On Change".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.