How do you get URL parameters in a Google Form using Google Apps Script?

后端 未结 2 1675
陌清茗
陌清茗 2020-12-10 14:17

So I\'ve got a Google Form where I\'d like to pass in a parameter from an email link like this:

https://docs.google.com/URL/forms/d/LONGSTRING/viewfor

相关标签:
2条回答
  • 2020-12-10 14:42

    I am assuming you are trying to get the form id?

    You will need to set up a trigger that will run on form submit.

    function onSubmit(){
    
      var form = FormApp.getActiveForm();
      var formID = form.getId();
    
    }
    
    0 讨论(0)
  • 2020-12-10 14:48

    I think you can't use your own id, you have to use the id of the Google Form's "Item" object. You can figure out the id by viewing a prefilled form. In the Form edit screen, click "Responses", "Get Pre-filled URL". Fill in the field that you want to use and click Submit. On the new page, you are given a URL in "Share this link to pre-fill the responses" . Examine that url and you can see "get" arguments like ?entry.265525444=mytext . Replace mytext with whatever you want to be in the field.

    This will display the field on your form, however. I myself was searching for how to make such a field readonly or invisible when I got here, but I hope this shows you a new direction to try.

    0 讨论(0)
提交回复
热议问题