1
votes

Is it possible to somehow distinguish between the first submission of google form and remaining submissions of same form where user is just updating his previous response?

I have used onSubmit trigger where email notifications are sent every time user submits a form. The problem is that the same email is triggered when the same user updates his form (i.e. when he's made a mistake). I would like to either stop these emails to being sent on update or change the email message?

Can you please suggest if it is possible to achieve this? I think onChange(e) might work.

1

1 Answers

1
votes

In the sheet that collects form submissions, the edited entries have a note "Responder updated this value". The script can get these notes; if at least one is nonempty, then it's an edit. Here is an example of a script (to be triggered by form submission) that sends different emails for new and edited entries.

function notify(e) {
  if (e.range.getNotes()[0].join('')) {
    MailApp.sendMail('[email protected]', 'updated entry', 'user edited submission');
  }
  else {
    MailApp.sendMail('[email protected]', 'new entry', 'user submitted form');
  }
}