4

How do I get responseId?

var form = FormApp.openById('myGoogleFormID');
var response = form.getResponse(responseId);

function onSubmit() {
  // Here I'd like to get the ID of the current response
}

I'd like to get the current ID of the response in order to manage a spreadsheet based on the values that were entered.

1 Answer 1

4

You can use this code.

Code

function onFormSubmit(e) {
  var responses = e.response;
  var lastResponse = responses[responses.length - 1];

  Logger.log(lastResponse.getId());
}

I wasn't able to find a clear cut solution, thus ended up with this. It will simply get the IDof the last entry

1
  • 1
    I ended up using the same approach as you but my case is quite friendly because the number of responses are always the same; so I can count on some constants for the indexes. itemResponses[INDEX_NUMBER].getResponse();
    – el.severo
    Commented Feb 26, 2014 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.