How to dynamically change an existing text item value on Google Forms using Google Apps Script

后端 未结 2 921
感动是毒
感动是毒 2020-12-22 09:55

I have an existing Google Form in which there is a TextItem with a title \"Which location was this performed at?\".

Whenever the form is loaded (opened), I

2条回答
  •  执念已碎
    2020-12-22 10:41

    You can't modify a form response filled by a user, you can either create a form response programmatically or edit a response after being submitted. The onOpen form trigger runs when someone opens the form to edit it rather than answer it [1]:

    This event does not occur when a user opens a form to respond, but rather when an editor opens the form to modify it.

    Moreover, triggers functions comes with an event parameter already defined [1] so you can't set your own function parameter(s) as you're doing with your loc parameter.

    EDIT

    You can programmatically create and submit a form response [2], from which you can also get a URL with a prefilled form for the user to finish [3].

    function populateMemberIds(loc){
      var form = FormApp.openById("[FORM-ID]");
      var questions = form.getItems();
      var response = form.createResponse(); 
    
      for (var i=0; i

    [1] https://developers.google.com/apps-script/guides/triggers/events#google_forms_events

    [2] https://developers.google.com/apps-script/reference/forms/form-response

    [3] https://developers.google.com/apps-script/reference/forms/form-response#toprefilledurl

提交回复
热议问题