0

I have made a Google Form and onSubmit an app script will run iterating through all form questions and answers however some questions, when the corresponding answer is left empty, are not listed/available in the iteration. Nevertheless, many questions whose answer is empty, are "listed" in the iteration.

function onSubmit(e) { var items = e.response.getItemResponses(); var emailBody = ''; for (i in items){ // the follwoing will not iterate all questions emailBody+= "<br/>"+ items[i].getItem().getTitle()+": "+items[i].getResponse(); } ......... other code follows ..... }

2

I think I got it! Items being left out from the list are checkboxes with no answer... from the Google documentation:

getItemResponses() Gets all item responses contained in a form response, in the same order that the items appear in the form. If the form response does not contain a response for a given TextItem, DateItem, TimeItem, or ParagraphTextItem, the ItemResponse returned for that item will have an empty string as the response. If the form response omits a response for any other item type, this method excludes that item from its returned array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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