When submitting a form via Apps script, if the form is set to collect the user e-mail for responses, then the code fails with error:
"Sorry, the form response could not be submitted. Please wait a few minutes and try again."
I think Google may have changed something as the code that worked last year is not working this year.
The error points at the "submit" line in the code. OR sometimes, the code runs, but still nothing appears in the sheet, or in the "responses" in the form itself.
If I turn off the option to collect e-mail, it runs fine and I see the submission in the Google sheet, just without an e-mail address.
I setup a test form, attached it to a new google sheet for responses, and pasted in my code:
function codeVoteDoVoteByForm()
{
// Get the Yes/No Google form
var myForm = FormApp.openById('File ID Here')
// Get a list of questions on it
var questions = myForm.getItems()
// Get question 0 (only one on this form) and mark it as multiple choice
var qt = questions[0].asMultipleChoiceItem()
// Set the users vote
var qr = qt.createResponse("I am here")
//Create the response
var FormResponse = myForm.createResponse()
var testemail = FormResponse.getRespondentEmail()
// Submit the response
FormResponse.withItemResponse( qr );
var myResponse = FormResponse.submit()
var responseString = myResponse.getTimestamp()
return "Vote recorded at " + responseString
}
My thought is that Google changed something, so now when running a script it's not able to get the users e-mail address for the formresponse, but I can't find any documentation to confirm this.
Any thoughts?