有没有办法删除存储在 Google 表单中的重复响应
Is there any way to delete duplicate response stored in Google Form
我想删除存储在 Google 表单中的重复回复。我发现有一种方法可以通过响应删除它,但我被困在这里。请帮助我。
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);
解决方案
如果您想删除重复的表单响应,您可以遍历响应数组并删除相同的响应。这段代码实现了您的目标(带有不言自明的注释):
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())
}
}
}
}
希望对您有所帮助。让我知道您是否需要其他任何东西或者您不明白什么。 :)
我想删除存储在 Google 表单中的重复回复。我发现有一种方法可以通过响应删除它,但我被困在这里。请帮助我。
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);
解决方案
如果您想删除重复的表单响应,您可以遍历响应数组并删除相同的响应。这段代码实现了您的目标(带有不言自明的注释):
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())
}
}
}
}
希望对您有所帮助。让我知道您是否需要其他任何东西或者您不明白什么。 :)