Build a Simple Google Form Add-on using Google Apps Script

What are Add-ons?

What goes into the making of an Add-on?

Step 1: Sample Google Form

Step 2: Create the Card

<div class="sidebar"><div class="block form-group"><p><b> Limit Form Responses</b> </p>
<input type="number" id="max_responses" name="max_responses" placeholder="Enter the Max Responses"/><button class="blue" id="load_responses">Set Limit</button></div>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>  $(function(){    
$('#load_responses').click(function({
google.script.run.limit_responses($('#max_responses').val());
});
<buttonid="load_responses" onclick="openResponsesWindow()">Set Limit</button>
}); </script>

Step3: Google Apps Script Code

function onOpen(){FormApp.getUi().createAddonMenu().addItem('Open','show_sidebar').addToUi();}
function show_sidebar() {var html = HtmlService.createTemplateFromFile("google_forms").evaluate().setTitle("Form Limitter Add-on");FormApp.getUi().showSidebar(html);}
function onformsubmit(){var limit_value = PropertiesService.getDocumentProperties().getProperty("limit");
var form = FormApp.getActiveForm();var len = responses.length;Logger.log(len)if (len == limit_value){

form.setAcceptingResponses(false);
}}

Step 4: Check the Output

Summary

Currently pursuing B Tech at MPSTME. Technical Blogger, interested in Google Workspace. Hope to remain a life long student.