我想删除存储在Google Form中的重复响应。我发现有一个方法来删除它与响应,但我卡在这里。请帮助我。
function deleteRes (){
var responseID = FormApp.openById('FormID').getResponses();
var id = FormResponse.getId();
var ss = SpreadsheetApp.openById("SheetID");
var s = ss.getSheetByName('Sheet3');
var r = s.getRange('A:A');
id.setValue();
responseID.deleteResponse(responseID);
如果您想删除重复的表单响应,您可以遍历resposse的数组,并删除那些相同的。这段代码实现了你的目标(带有自释性注释)。
function myFunction() {
// get the array will all the responses
var responses = FormApp.openById('Form ID').getResponses();
// compare all the responses with the rest of responses
for(i=0;i<responses.length;i++){
for(j=0;j<responses.length;j++){
// If the responses we are comparing are the same and they are different responses
// (that is why we compare their IDs) then we delete on of the responses
if(responses[i]==responses[j] && responses[i].getId()!=responses[j].getId()){
FormApp.openById('Form ID').deleteResponse(responses[j].getId())
}
}
}
}
我希望这对你有帮助。如果你还需要其他的东西,或者你有什么不明白的地方,请告诉我 :)