1
votes

I just tried my coding below...but the problem is, my google apps script just submit the form with blank value for both "short answer" field. Can someone show me somelight how i can solve my problem. TQ.

function myFunction() {
  var dapatkanForm = FormApp.openByUrl('https://docs.google.com/forms/d/1S1F3cKMwkXm3gVt00RegQ-GCzRfELOq74IH9WEk8SlU/edit?usp=sharing');
  var nama = dapatkanForm.getTitle();
  var listIsiText = dapatkanForm.getItems(FormApp.ItemType.TEXT);
  var panjangArray = listIsiText.length;
  for(var i=0; i<panjangArray; i++)
  {
    var textTemp = listIsiText[i];
    var nakSet = textTemp.asTextItem();
    var response = nakSet.createResponse('MOHD ANIS BIN AZINAN');
  }
  var formResponse = dapatkanForm.createResponse();
  formResponse.submit();
  Logger.log(nama);
}
1

1 Answers

0
votes

Your code is very close to the solution. You just need one additional method. The following line…:

var formResponse = dapatkanForm.createResponse();

…should end up looking like:

var formResponse = dapatkanForm.createResponse().withItemResponse(response);

By using .withItemResponse() the form submit will upload your responses instead of being void. Please, ask me for more clarifications if you still need help.