[英]Fill Google form using Google Apps Script
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);
}
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.通过使用
.withItemResponse()
表单提交将上传您的回复而不是无效。 Please, ask me for more clarifications if you still need help.如果您仍然需要帮助,请向我询问更多说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.