Search code examples
formsgoogle-sheetsgoogle-forms

Trigger an email when a name is selected from a drop down box.. Google forms / sheets


Trigger an email if field reads selected text..

In the response sheet - I have a column called "Assigned To". I have a drop down list with 3 names. Can I trigger an email to be sent to their email address if a persons name is selected?

Here is my code so far:

unction myNotification(e) {
if( e.values[9] == "Barry" ) {
  var email = "[email protected]";
  MailApp.sendEmail(email, "Test", "Yes is Barry");

Thanks in advance


Solution

  • Using an installable onEdit trigger, try:

    function sendNotification(e) {
    if (e.value == 'Barry' && e.range.columnStart == 4 && e.range.rowStart > 1) {
        var email = '[email protected]';
        MailApp.sendEmail(email, 'test subject', 'This is Barry')
        }
    }
    

    and see if that works ?