How to show all answers in confirmation message of current submission in google form using appscript

31 Views Asked by At

I used below script but I got message from the previous submission, not the current one.

function onSubmit(e) {
  var form = FormApp.getActiveForm();
  var response = e.response;
  // Get all the item responses
  var itemResponses = response.getItemResponses();
  var message = "Thank you for registering for registration. Here are your registration details:\n\n";
  // Iterate through each item response
  for (var i = 0; i < itemResponses.length; i++) {
    var itemResponse = itemResponses[i];
    var question = itemResponse.getItem().getTitle();
    var answer = itemResponse.getResponse();
    // Append question and answer to the message
    message += question + ": " + answer + "\n";
  }
  // Set confirmation message
  form.setConfirmationMessage(message);
}

If I tried to edit the old submission and submited again, then received the current one

0

There are 0 best solutions below