简体   繁体   中英

Google Form - not filled fields

I started to use a Google Form recently. I created:

  1. The Google form with some questions,
  2. Spreadsheet where the script would put the answers
  3. An template that would be filled with the answers, converted to PDF and sent to the e-mail address.

Everything works perfectly IF all the Google Form fields had been filled.

If there is at least one field that was left empty - all the answers are put correctly to the spreadsheet but get totally misplaced in the template... (fragment of my code below)

// When Form Gets submitted
function onFormSubmit(e) {
//Get information from form and set as variables
var email_address = "myemail@myemail";
var project_name = e.values[1];
var owner = e.values[2];
var team_members = e.values[5];
var project_initiator = e.values[6];
var stakeholders = e.values[7];
var deadline = e.values[3];
var related_projects = e.values[8];
var deliverables = e.values[4];
var project_summary = e.values[9];
var contribution = e.values[10]; 


// Replace place holder keys,in our google doc template
copyBody.replaceText('keyProjectName', project_name);
copyBody.replaceText('keyOwner', owner);
copyBody.replaceText('keyTeamMembers', team_members);
copyBody.replaceText('keyProjectInitiator', project_initiator);
copyBody.replaceText('keyStakeholders', stakeholders);
copyBody.replaceText('keyDeadline', deadline);
copyBody.replaceText('keyRelatedProjects', related_projects);  
copyBody.replaceText('keyProjectSummary', project_summary);
copyBody.replaceText('keyContribution', contribution);

And a fragment of the template:

http://zapodaj.net/images/ce3895cc6614f.png

Thank you for any advises, answers..

The easiest way to fix this issue would be to make all of the questions from your form a required questions. That way, the user will be unable to leave an answer blank and your template will auto-populate in the correct order.

Hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM