I'm running a form, which feeds into a Google Sheet. We're running into the issue of users clicking submit multiple times resulting in multiple submissions of the same information in rapid-fire succession. However, we also have user come back at a later date and fill out a new form.
I've found how to remove duplicate entries - but is it possible to also define the script to only remove them if they were submitted on the same day? The form automatically adds a timestamp in this format: 8/15/2016 16:39:27
My script is as follows:
function removeDuplicates() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var newData = new Array();
for(i in data){
var row = data[i];
var duplicate = false;
for(j in newData){
if(row[3] == newData[j][3] && row[4] == newData[j][4]){
duplicate = true;
}
}
if(!duplicate){
newData.push(row);
}
}
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}
It checks columns D (3) and E (4) (which correspond to the user's zip code and email address) for duplicates.
I can share the sheet if needed - it has both email addresses and home addresses of our users, so I'd need to re-populate with dummy data!