Google表单 - 未填写的字段

时间:2014-07-22 08:49:32

标签: google-apps-script field google-form

我最近开始使用Google表单。我创建了:

  1. 包含一些问题的Google表单,
  2. 电子表格,脚本会将答案放在哪里
  3. 将填充答案,转换为PDF并发送到电子邮件地址的模板。
  4. 如果所有Google表单字段都已填写,那么一切都很完美。

    如果至少有一个字段留空 - 所有答案都正确地放到电子表格中但在模板中完全放错地方......(我的代码片段在下面)

    // 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);
    

    模板的一个片段:

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

    感谢您的任何建议,答案..

1 个答案:

答案 0 :(得分:0)

解决此问题的最简单方法是将表单中的所有问题都作为必填问题。 这样,用户将无法将答案留空,您的模板将以正确的顺序自动填充。

希望有所帮助