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"; // <-- Replace with your real sheet Name 

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

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

      if (!query) {

        return HtmlService.createHtmlOutput("Missing query");

      }

      const sheet = SpreadsheetApp.openById(sheetId).getSheetByName(sheetName);

      const range = sheet.getRange(2, columnToSearch, sheet.getLastRow() - 1, 1);

      const finder = range.createTextFinder(query)

        .matchEntireCell(true)   // Exact match

        .matchCase(false);       // Case-insensitive

      const match = finder.findNext(); // FIRST MATCH ONLY

      if (!match) {

        return HtmlService.createHtmlOutput("No matching row found");

      }

      const row = match.getRow();

      const data = sheet.getRange(row, 1, 1, sheet.getLastColumn()).getValues()[0];

      return ContentService.createTextOutput(

        JSON.stringify({

          row: row,

          data: data

        })

      ).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 Prefill section and add a Prefill-Webhook field. 

  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 URL Parameter 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.