Google Forms – How to Get Response ID via Google Apps Script

google-apps-scriptgoogle-forms

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 the the current id of the response in order to manage a spreadsheet based on the values that were entered.

Best Answer

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