雖然不知道為什麼會有一部份
undefine,但至少有一部份完成取得作業了!!!!!
code參考這裡:https://gist.github.com/pierandrea/3fcccada803ca34c9e09
function assignEditUrls() { |
|
var form = FormApp.openById('yourFormKey'); |
|
//enter form ID here |
|
|
|
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('yourWorksheetName'); |
|
|
|
//Change the sheet name as appropriate |
|
var data = sheet.getDataRange().getValues(); |
|
var urlCol = ; // column number where URL's should be populated; A = 1, B = 2 etc |
|
var responses = form.getResponses(); |
|
var timestamps = [], urls = [], resultUrls = []; |
|
|
|
for (var i = 0; i < responses.length; i++) { |
|
timestamps.push(responses[i].getTimestamp().setMilliseconds(0)); |
|
urls.push(responses[i].getEditResponseUrl()); |
|
} |
|
for (var j = 1; j < data.length; j++) { |
|
|
|
resultUrls.push([data[j][0]?urls[timestamps.indexOf(data[j][0].setMilliseconds(0))]:'']); |
|
} |
|
sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls); |
|
} |
|
其實我原本並沒有這需求,但後來發現,隨著填寫的資料越來越多,寫錯字需要修改的、意見需要加註的部分,其實對修改內容這個功能多少還是有需求,所以我找了很多解法,
一開始用的解法,不知道為什麼,for迴圈似乎故障了,每個for只跑一筆出來,所以必須運算N+1次然後每次會吐N+1行資料,五十幾筆用了一千多列還算不完........
留言列表