0
我有一個只有幾個字段的簡單表單。我需要從電子表格加載數據並創建表單響應。我需要10000個響應,例如序號1-10,000作爲唯一的條目。其餘的字段將是空的。使用表單中的腳本加載表單響應 - 僅使用ID號創建初始表單
我有一個只有幾個字段的簡單表單。我需要從電子表格加載數據並創建表單響應。我需要10000個響應,例如序號1-10,000作爲唯一的條目。其餘的字段將是空的。使用表單中的腳本加載表單響應 - 僅使用ID號創建初始表單
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
};
};
謝謝桑迪。這個腳本正在做我所需要的。唯一的問題是,它運行時,我收到了一打或更多循環後的錯誤。錯誤是「對不起,表單響應無法提交。」我嘗試在循環中放入utilities.sleep(200)來減慢速度。我添加了一行來查看有多少響應,並調整了for循環從結束的地方開始。然而,這需要很長時間才能輸入10,000個響應。有任何想法嗎? –
對不起,算了一下。我有另一個腳本在同一時間運行也訪問表單。關閉劇本,好走了。謝謝! –