Tuesday, 15 February 2011

Google sheets script that sends a notification upon form submission if data is recorded in a specific column -



Google sheets script that sends a notification upon form submission if data is recorded in a specific column -

i'm trying create script new google sheets sends notification if form submitted , contains info in specific column.

in example, if question populates info in column e answered in form, email notification link spreadsheet.

in below script, if set trigger on edit work if column e edited. cannot work on form submit, however. can help fixing script work on edit?

thanks!

function sendnotification() { var ss = spreadsheetapp.getactivespreadsheet(); var sheet = ss.getsheetbyname("form responses"); var cell = ss.getactivecell().geta1notation(); var row = sheet.getactiverange().getrow(); var cellvalue = ss.getactivecell().getvalue().tostring(); var recipients = "email@email.com"; var subject = 'subject'; var body = 'body'; if (cell.indexof('e')!=-1) { mailapp.sendemail(recipients, subject, body); }

when script runs on form submission trigger , there no such thing active cell, form info inserted in lastly row of sheet. have @ lastly row , check right column (getlastrow() , column 5 "e").

google-apps-script google-spreadsheet google-form

No comments:

Post a Comment