无论如何,当使用应用程序脚本提交时,我可以获得谷歌表单的网址

时间:2017-04-08 09:46:55

标签: javascript google-apps-script

我正在尝试在google表单的url中传递一个查询参数并将该表单提交给其他人来填充它,所以我希望onSubmit事件检查该查询参数并获取它。

我在onSubmit事件上有以下代码,如下所示:

function onFormSubmit(e){
  var formResponses = FormApp.getActiveForm().getResponses();
  var formResponse = formResponses[formResponses.length-1];
  var itemResponses = formResponse.getItemResponses();

  for (var j = 0; j < itemResponses.length; j++) {
    var itemResponse = itemResponses[j];
    Logger.log('Last response to the question "%s" was "%s"',
               itemResponse.getItem().getTitle(),
               itemResponse.getResponse());
  }

  var me = Session.getActiveUser().getEmail();
  GmailApp.sendEmail(me, 'Google Form Notification Submission', 'Test');

}

当用户填写表单时,我发送的网址为https://docs.google.com/forms/d/e/xyxyxyxyxyxyyx/viewform?usp=sf_link?patient_id=33333,如何在formSubmit上获取patient_id?

1 个答案:

答案 0 :(得分:1)

Google表单仅处理用于预填表单的参数。要了解如何预填Google表格,请参阅Send your form to peopleIs it possible to 'prefill' a google form using data from a google spreadsheet?发送包含预先填写的答案的表单。

在评论中,Jack Brown shared指向Get URL Link to a "SECTION" only的链接,其中包含answer,其中包含用于投放HTML /的Web应用程序代码JavaScript / CSS表单。在Sandy Good的另一个问题的comment上,她还评论说,Google表单中不包含预期的Google表单行为/ Google表单功能,并且您可以使用Google Apps脚本网络应用程序作为另类。