Reputation: 21
How can I get an email when a specific tab has a row added? How can I add more than one email address to be notified of the change to a the tab?
I need a Google App Script to notify me and specific others in my workplace by email when there has been a change to a specific tab in a Google sheet. Notification rules is too broad and triggers for any change to the whole workbook.
I tried an App Script, but it is still sending emails for changes to any tab in the entire workbook...not the specific tab.
Upvotes: 2
Views: 821
Reputation: 1987
You can use an installable on change trigger and check if the event type is INSERT_ROW
. Although it doesn't mention it on that page (but it's mentioned here), the event object also includes its source, so you can use it to get the name of the modified sheet:
function newRowAdded(event) {
const monitoredSheetName = 'Clients';
const emailAddresses = ['[email protected]', '[email protected]'];
if (event.changeType === 'INSERT_ROW' &&
event.source.getActiveSheet().getName() === monitoredSheetName)
{
MailApp.sendEmail(
emailAddresses.join(','),
'New row added!',
'A new row has been added to sheet ' + monitoredSheetName
);
}
}
Upvotes: 2