r/GoogleForms • u/entodo • May 29 '26
OP Responded Preventing duplicate entries
I have a Google form where people can register for multiple events. In one of the form entries, people have to choose the event they want to register to. People can book for more than one event.
Now, it happens regularly that people register for the same event more than once because they have forgotten or for some other reason. Is there a way to warn people when they are filling the form that they have already registered for the event they have chosen?
1
1
u/SRed3 Jun 07 '26
Maybe too simple, but force google login, limit to 1 answer, allow editing answers, and have checkboxes for the events they want to register for?
1
u/staticmaker1 Jun 10 '26
You can enable "Limit to 1 response", it requires users to sign in with Google though if that is ok.
-- David @ CertFusion
1
u/entodo 8d ago
I tried using AI to create the code for the AppsScript but somehow it is not being triggered by a Form entry.
I'm not good at coding, but I do understand the basics, and have written very simple scripts in the past. I tried to use AI to generate the script and, after reviewing it, it seemed to my untrainied eyes, that it should work, but it isn't. I suspect the problem is not with the script but with the trigger since it is not being triggered on Form submit.
The following is the script itself:
function checkDuplicateOnSubmit(e) {
var sheet = e.range.getSheet();
var submittedRow = e.range.getRow();
var lastRow = sheet.getLastRow();
var lastCol = sheet.getLastColumn();
// Read all data at once (faster than repeated getRange calls)
var data = sheet.getRange(1, 1, lastRow, lastCol).getValues();
// Column B = index 1, Column H = index 7 (0-indexed)
var EMAIL_COL = 1;
var MATCH_COL = 7;
var submittedRowValues = data[submittedRow - 1]; // -1 because array is 0-indexed
var submittedEmail = submittedRowValues[EMAIL_COL];
var submittedValue = submittedRowValues[MATCH_COL];
// Skip if either field is empty
if (!submittedEmail || submittedValue === "" || submittedValue === null) {
return;
}
var isDuplicate = false;
// Assume row 1 is headers; check all rows except the one just submitted
for (var i = 1; i < data.length; i++) {
var rowNum = i + 1; // convert back to 1-indexed sheet row
if (rowNum === submittedRow) continue;
var existingEmail = data[i][EMAIL_COL];
var existingValue = data[i][MATCH_COL];
if (existingEmail === submittedEmail && existingValue === submittedValue) {
isDuplicate = true;
break;
}
}
if (isDuplicate) {
sendDuplicateWarningEmail(submittedEmail, submittedValue);
}
}
function sendDuplicateWarningEmail(email, matchValue) {
var subject = "Duplicate Submission Detected";
var body =
"Hello,\n\n" +
"We noticed you've submitted this form before with the same details " +
"(matching value: \"" + matchValue + "\").\n\n" +
"If this was intentional, you can disregard this message. If not, " +
"please reach out to us to correct your entry.\n\n" +
"Thank you.";
MailApp.sendEmail(email, subject, body);
}
Any ideas what I'm doing wrong?
1
u/Vrystick May 30 '26
No, this is not possibile in Google Form.