我有一个只有几个字段的简单表单。我需要从电子表格加载数据并创建表单响应。我需要10,000个响应,例如序列号1-10,000作为唯一条目。其余字段将为空。
答案 0 :(得分:1)
var myFormID = 'Put_Form_ID_Here';
var howManyToSubmit = 10;//How many form submissions
function makeResponses(id,howMany) {
var allQuestionItems,firstQuestion,frm,i,newAnswer,newRezpnz;
id = id?id:myFormID;//If an id was passed to the function - use it
if (!id) {return;};//If there is no id to get the Form - quit
frm = FormApp.openById(id);//Get a reference to the Form
allQuestionItems = frm.getItems();//Get all questions in the Form
firstQuestion = allQuestionItems[0];
for (i=1;i<howManyToSubmit;i+=1) {
newRezpnz = frm.createResponse();
//Logger.log('thisAnswer: ' + thisAnswer)
newAnswer = firstQuestion.asTextItem().createResponse(i.toString());
newRezpnz.withItemResponse( newAnswer );
newRezpnz.submit();//submit a new response
};
};