Restrict users from submitting multiple entries to a Google Form

Google forms can be used to make vote or survey. However, it can not prevent multiple submission. Here is a Google Apps Script “voTer” to solve this problem. For each submission, the script will compare the “username” with previous recorded usernames. If the username is existed, then the new submission will be deleted. At the same time, an email will be sent to that person for notification. Please do tailor the highlighted part in the script to fit your situation.

Here is the apps script code.

To use this code, you need to;

  • check “Require ORGANIZATION sign-in to view this form”;
  • check “Automatically collect respondent's ORGANIZATION username”.;
  • Also you need to add an “on form submit” trigger to this code.;
  • Change the email body according to your situation.;

Check out this video for detail information. http://www.youtube.com/watch?v=dgg8Oq6-RjE;


function voTer(){
 var sss = SpreadsheetApp.getActiveSpreadsheet();
 var form = sss.getSheetByName("Sheet1");
 var range = form.getRange(1,2,form.getLastRow(),1);
 var lastEntry = range.getCell(form.getLastRow(),1).getValue();
 var data = form.getRange(1,2,form.getLastRow()-1,1).getValues();
 for (var i = 0; i < data.length; i++) {
 var row = data[i];
 var entry = row[0]; 
 if (entry == lastEntry){
var subject = "You Have Submited!"; //Email subject
var recipient = lastEntry;
var body = "Hi there,

You've already submited this form before, so this submission will not count.
Please contact ***, if you do want to change your answer.

Best,
***"; //Email body
if (recipient!=''){
 MailApp.sendEmail(recipient, subject, body,{htmlBody:body});
 }
 form.getRange(form.getLastRow(),2,1,form.getLastColumn()).clear();
 break; 
 }
 }
}