I am working with google forms via app script. I want to determine if the current form that is being submitted is in edit mode or a new response? How can I check this in the onSubmit event.
If yes that user is edit a previously submitted response than I want to change the value in my spread sheet to "yes".
below is a snippet of my code:
function testExcel2() {
var email = "email";
var s = SpreadsheetApp.openById("id");
var sheet = s.getSheets()[0];
var headers = sheet.getRange(1,1,1,sheet.getLastColumn() - 1).getValues()[0];
var datarow = sheet.getRange(sheet.getLastRow(),1,1,sheet.getLastColumn() - 1).getValues()[0];
var message = "";
for(var i in headers)
{
message += "" + headers[i] + " : " + datarow[i] + "\n\n";
}
MailApp.sendEmail(email, "Submitted Data Test", message);
var af = FormApp.getActiveForm();
//af.setCustomClosedFormMessage("The form is currently processing a submission, please refresh the page.");
af.setConfirmationMessage('Thanks for responding!')
//af.setAcceptingResponses(false);
var rowKey = "o" + sheet.getLastRow();
var editCell = sheet.getRange(rowKey).setValue('no');
}
FormApp.getActiveForm().getResponses();
Then get the length of the array that is returned, and get the last response. Is that how you tested getting the last response? If there is a way to get the current response, and then find it's index in the array, and it's not the last element, then it might work. – Ennoble