0

The sheet was created as part of an RSVP process to an event. By checking the Location Check box in Column 14, an email with our location will be sent to the recipient in Column 2.

This is the script I have. I have played with it so much, changing around so many little things, but nothing seems to work.

function onEdit()
{

const sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetName();  
const activeCell = SpreadsheetApp.getActiveSpreadsheet().getActiveCell();

    if( activeCell.getColumn() == (14) && activeCell.getRow > 2 )
    {
      const recipient = activeCell.offset(0,-12).getValue(); 
      const workshopDate = activeCell.offset(0,-9).getValue();
      
      MailApp.sendEmail
      ( 
        recipient, "Here's where to find us for the Interview Workshop ",
        "Hi there,"+ "/n" + "/n"+ 
        "Thank you so much for confirming that you will be joining us for our interview workshop on " + workshopDate + ". " + "/n" +
        "The workshop will be held at ________________" + "/n" +
        "Registration is from 8h00 - 8h30, we will begin promptly at 9 and finish between 3h00 and 3h30" + "/n" + "/n" +
        "We're really looking forward to seeing you there!" + "/n" +
        "- The Enbaya Careers Team"
      );

    };
  
};

Any ideas?

You can try this. (Sorry the question was already closed so I just posted this here to give you an example that uses the event object to take a look at) Try using an installable trigger for the function. Be sure when you use an installable trigger to change the name otherwise you get two triggers.

function onMyEdit(e) {
  const sh = e.range.getSheet();
  if (sh.getName() == 'Sheet1' && e.range.columnStart == 14 && e.range.rowStart > 2 && e.value == 'TRUE') {
    const recipient = e.range.offset(0, -12).getValue();
    const workshopDate = e.range.offset(0, -9).getValue();
    MailApp.sendEmail(
      recipient, "Here's where to find us for the Interview Workshop ",
      "Hi there," + "/n" + "/n" +
      "Thank you so much for confirming that you will be joining us for our interview workshop on " + workshopDate + ". " + "/n" +
      "The workshop will be held at ________________" + "/n" +
      "Registration is from 8h00 - 8h30, we will begin promptly at 9 and finish between 3h00 and 3h30" + "/n" + "/n" +
      "We're really looking forward to seeing you there!" + "/n" +
      "- The Enbaya Careers Team"
    );

  };

}

I didn't debug it

Cooper
  • 59,616
  • 6
  • 23
  • 54
  • You are using services (MailApp) that require authorization and therefore a simple `onEdit` can not work. Solution: change function the name from `onEdit` to whatever else you like and then create an **installable trigger** for that function. You can do that either programmatically or from the project's trigger menu. See duplicate post for more information. – Marios Apr 19 '21 at 15:10
  • Also you would come across with the exact error message if you went to the execution page. In this way you can find and search for specific error messages but also log values that you want to test during the development process of your trigger (onEdit) function. Otherwise you are developing in blind mode. – Marios Apr 19 '21 at 15:14
  • @soMario - There are no errors to the script, which is why it boggles my mind! I set up a trigger for the onEdit specifically. In the past I used onEdit and it worked, but I'll change the trigger and the function name, see if that works. – Nathaly Wheller Apr 19 '21 at 15:58
  • There are errors but you can't see them by running the function because that function is a **trigger** function and it is not supposed to be manually executed. To see the errors you get read this stackoverflow thread: [How to debug Google Apps Script (aka where does Logger.log log to?)](https://stackoverflow.com/questions/11539411/how-to-debug-google-apps-script-aka-where-does-logger-log-log-to). I also mentioned **go to the execution page** in my previous comment. – Marios Apr 20 '21 at 07:55

0 Answers0