在Google表脚本编辑器中,我使用下面的代码在电子表格中插入编辑响应链接以及表单数据。
function assignEditUrls() { var form = FormApp.openById('xxxxxxxxxxxxxxxxxxxxxxxx'); //enter form ID here var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses'); //Change the sheet name as appropriate var data = sheet.getDataRange().getValues(); var urlCol = 3; // 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][1]?urls[timestamps.indexOf(data[j][0].setMilliseconds(0))]:'']); } sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls); }虽然这应该工作到上周,当脚本现在运行时,我收到以下错误:
TypeError: Cannot find function setMilliseconds in object . (line 18, file "Code")我们将非常感激地提出任何想法或替代解决方案。
In the Google sheet script editor, I'm using the code below to insert the Edit response link in the spreadsheet along with the form data.
function assignEditUrls() { var form = FormApp.openById('xxxxxxxxxxxxxxxxxxxxxxxx'); //enter form ID here var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses'); //Change the sheet name as appropriate var data = sheet.getDataRange().getValues(); var urlCol = 3; // 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][1]?urls[timestamps.indexOf(data[j][0].setMilliseconds(0))]:'']); } sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls); }Whilst this was working as it should up till last week, when the script is now run I get the following error:
TypeError: Cannot find function setMilliseconds in object . (line 18, file "Code")Any thoughts or alternative solutions would be gratefully received.
最满意答案
这段代码为我运行,没有任何问题,也没有修改,所以无论你的错误是什么,它都是临时的,或者不是这部分脚本。
编辑:再次尝试再次确认并且执行记录确认给我:'[14-11-18 23:17:52:820 GMT]执行成功[0.581秒总运行时间]'我看到了链接显示在电子表格中没有问题。
This code runs for me with no issues and no modification, so whatever your error is, it's either temporary, or not with this portion of the script.
Edit: Just tried it again to be doubly sure and the execution transcript is confirming for me: '[14-11-18 23:17:52:820 GMT] Execution succeeded [0.581 seconds total runtime]' and I'm seeing the links appear in the spreadsheet no issue.
更多推荐
发布评论