How to prefill Zoho Forms with data from Google Sheets using webhooks

How to prefill Zoho Forms with data from Google Sheets using webhooks

Zoho Forms allows you to dynamically prefill form fields with data fetched from external sources. One popular use case is pulling customer data stored in a Google Sheet and pre-populating your forms when the user opens them. This saves time, reduces errors, and improves the user experience.

In this article, we’ll walk you through the step-by-step process of setting up a Google Sheets Apps Script, deploying it as a web app, and integrating it with Zoho Forms via Dynamic Prefill Webhooks.

Check out a quick video on how to configure this.


  1. Open the Google Sheet where your data is stored.


  2. From the top menu, click:
    Extensions → Apps Script.


  3. This will open the Apps Script editor in a new tab.

  4. Copy and paste the following script:

    function doGet(e) {

        

      const sheetId = "{sheet_id}"; // <-- Replace with your real sheet ID 

      const sheetName = "Sheet1";

      const columnToSearch = 1; // e.g., Column B = 2

      const query = e.parameter.query || ""; // Example: ?query=Doe


      if (!query) {

          return ContentService

        .createTextOutput(JSON.stringify({ message: "Missing search query" }))

        .setMimeType(ContentService.MimeType.JSON);

      }


      const ss = SpreadsheetApp.openById(sheetId);

      const sheet = ss.getSheetByName(sheetName);

      const data = sheet.getDataRange().getValues();


      for (let i = 0; i < data.length; i++) {

        const cellValue = data[i][columnToSearch - 1].toString();

        if (cellValue.includes(query)) {

          const result = {

            row: i + 1,        // Optional: 1-based row number

            data: data[i]      // Entire matching row

          };

          return ContentService

            .createTextOutput(JSON.stringify(result))

            .setMimeType(ContentService.MimeType.JSON);

        }

      }


      return ContentService

        .createTextOutput(JSON.stringify({ message: "No matching row found." }))

        .setMimeType(ContentService.MimeType.JSON);

    }

  5. Copy the sheetId from your Google Sheet URL as shown.

  6. Replace the sheetId from your Google Sheet URL.



  7. Replace the name of the sheet as shown with the sheet name.

  8. Replace the column where your unique identifier (e.g., email, ID) is stored. Use numbers:
    For example, if you want to search by email stored in column B, set: const columnToSearch = 2;


  9. In the Apps Script editor, click the Deploy button in the top-right corner and select New deployment.


  10. Under Select type, choose Web app.


  11. Fill out the details:

    • Description: Enter something like Fetch data API.

    • Execute as: Me (your account).

    • Who has access: Anyone.


  12. Click Deploy.

  13. The first time you deploy, Google will ask for permissions. Click Authorize.


  14. After deployment, Google will provide you with a Web App URL.


  15. You can test the script in your browser with a value from your sheet’s search column.


  16. It  will return a JSON response containing that row’s data.


  17. Open your form builder in Zoho Forms. Go to Settings > Form Settings > Prefill > Dynamic Prefill Webhook.

  18. Under Webhook Settings, select Employee ID as the Search Field. Make sure the field you select here matches the column you set as columnToSearch in your Google Script.

  19. Under Webhook URL, paste the Web App URL you copied.

  20. Enter the Record Identifier as query. Click Next


  21. Test the webhook with search field value like 1002 and check if the received response is valid.

  22. Map the fields from your sheet’s response to the corresponding form fields.


  23. Click Save.

Now, when a respondent opens the form, enters their Employee ID and clicks the search icon, the form will call the Google Sheet, fetch details, and prefill the form automatically.


      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              WCAG



                                        Create. Review. Publish.

                                        Write, edit, collaborate on, and publish documents to different content management platforms.

                                        Get Started Now







                                                          You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                              Manage your brands on social media


                                                                • Desk Community Learning Series


                                                                • Digest


                                                                • Functions


                                                                • Meetups


                                                                • Kbase


                                                                • Resources


                                                                • Glossary


                                                                • Desk Marketplace


                                                                • MVP Corner


                                                                • Word of the Day


                                                                • Ask the Experts


                                                                  Zoho Sheet Resources

                                                                   

                                                                      Zoho Forms Resources


                                                                        Secure your business
                                                                        communication with Zoho Mail


                                                                        Mail on the move with
                                                                        Zoho Mail mobile application

                                                                          Stay on top of your schedule
                                                                          at all times


                                                                          Carry your calendar with you
                                                                          Anytime, anywhere




                                                                                Zoho Sign Resources

                                                                                  Sign, Paperless!

                                                                                  Sign and send business documents on the go!

                                                                                  Get Started Now




                                                                                          Zoho TeamInbox Resources





                                                                                                    Zoho DataPrep Demo

                                                                                                    Get a personalized demo or POC

                                                                                                    REGISTER NOW


                                                                                                      Design. Discuss. Deliver.

                                                                                                      Create visually engaging stories with Zoho Show.

                                                                                                      Get Started Now









                                                                                                                          • Related Articles

                                                                                                                          • Google Sheets Integration

                                                                                                                            Overview If you are looking to automate storing your form responses in a sheet and save the time spent on manual entry of form data into the sheet, you can use the Zoho Forms - Google Sheets integration. With this integration, your form responses ...
                                                                                                                          • Field Alias - Prefill URL

                                                                                                                            Table of contents What is prefilling form fields? Why is prefilling forms important? What is Field Alias? Set Field Alias Generate a prefilled form URL Manually create the URL of a prefilled form Prefill a Multiple Choice Field Prefill a Dropdown ...
                                                                                                                          • Creating your first web form in Zoho Forms

                                                                                                                            This walkthrough is to help you get started with creating a form using Zoho Forms. Follow the simple step-by-step instructions given below to build forms that perfectly match your requirements. Creating a new account To build a form using Zoho Forms, ...
                                                                                                                          • Configuring a Webhook

                                                                                                                            In simple terms, a webhook is a way for one system or application to send real-time data to another system or application as soon as an event occurs. A webhook is basically a notification that is sent to a destination (URL) when an event occurs. With ...
                                                                                                                          • Saving attachments to Google Drive

                                                                                                                            If your form has attachment and signature fields, you can choose to save them in Google Drive using this integration. To do this, Select Yes to store file attachments and signatures under Google Drive. Select the Attachment and Signature fields that ...
                                                                                                                            Wherever you are is as good as
                                                                                                                            your workplace

                                                                                                                              Resources

                                                                                                                              Videos

                                                                                                                              Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                              eBooks

                                                                                                                              Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                              Webinars

                                                                                                                              Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                              CRM Tips

                                                                                                                              Make the most of Zoho CRM with these useful tips.



                                                                                                                                Zoho Show Resources