Question

I want to pre-fill a Google form such that some of the fields which are pre-filled, are the responses from another form. What i mean to say is that i send out a few columns of the responses of one of my forms and get the information validated by a third party. Is this kind of pre-filling possible?

Was it helpful?

Solution

function sendForm(e) {  
  //Code to open second form and get the items of the form
  var form = FormApp.openById('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');   
  var items = form.getItems();
  var formItem = items[0].asTextItem();   
  var formResponse = form.createResponse();

  var count=0;

  var response = formItem.createResponse(e.namedValues["Name"].toString());     
  formResponse.withItemResponse(response);

  formItem = items[1].asTextItem();
  response = formItem.createResponse(e.namedValues["Email"].toString());        
  formResponse.withItemResponse(response);

  //Creates URL with pre-filled data
  var url = formResponse.toPrefilledUrl();

  //Mail the link to the people required.
}

This code goes in the response sheet of the first form and a trigger must be added to call this function every time a form submit action happens.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top