How to Auto-Fill Zoho Form Fields from Zoho CRM with Dynamic Webhooks

Auto-populate field values from Zoho CRM in the Zoho Form using Dynamic Webhook

Requirement Details:

Zoho Forms allows you to integrate with Zoho CRM where we can add the required fields and send it to your customers thus facilitating data collection. With this Zoho CRM and Zoho Forms integration, you can push the form entries directly into Zoho CRM modules and pre-populate certain data such as name, email, etc. from Zoho CRM in your form.  However, In this Custom Solution - We're able to Auto-Populate the Forms field with the Zoho CRM - Record Data without the Integration Field by the use of the Dynamic Prefill - Webhook method. 

Business Use-Case: 

Consider you would like to Collect the Product informations that you're customer would like to buy using the Zoho Forms and thus you would like to Dynamically Display the Product informations like Product Price, Product Availability when the Customer Chooses the Respective Product which is available in your Zoho CRM organisation - Product Module Record. In this Case, Without the CRM - Forms integration we'll be able to Pre-populate by using the Zoho CRM Function Call using REST APIs to be Utilised in the Dynamic Prefill - Webhook in Zoho Forms. 

Zoho Forms Configuration: 

We need to Configure the Required fields like the Customer informations - Name, Email, Contact Number, etc. In addition to it, You need to add the Fields for the Product that needs to be displayed in the Form to be Auto-Populated with the Zoho CRM - Products Record. There should be the Primary Field for the Products in the Zoho Forms Layout to allow the Client to Choose the required Product, Either It can be the Single Line field or a Drop-down field to display the Pre-Defined Product Choices. Using the Primary field, We'll search the record in Zoho CRM to fetch the Field Values. 

We should be aware about the Field type [Since it involves the Search Record Task from CRM] for the Primary field in the Zoho Form selected to Search the Record the record in Zoho CRM. Also, For the Fields needs to be selected for the Auto-Population, We'll be only able to Map the Fields based on their Field type output from Zoho CRM - Search Record Deluge Task

For Example, We've Selected the Drop-down field in Zoho Forms to display the Pre-Defined Products as Options for the Customers to Choose and we selected the Fields to be Auto-Populated as Product - Unit Price, Product - Availability status and the Product type.



Zoho CRM Configuration: 

We need to create Standalone Functions in Zoho CRM and make them be available as API calls. If the function needs to be triggered without employing these methods or from external sources, you can create standalone functions and make them available as API calls. Triggering functions through REST APIs which gives the flexibility to trigger it from anywhere inside Zoho CRM or from any other application.

  1. Go to Zoho CRM > Setup > Developer Hub > Functions.
  2. In the My Functions page, click + Create New Function.
  3. Choose a Category of the function as Standalone.
  4. Click Create.

Use the below Script:

  1. grec = zoho.crm.searchRecords("Products","(Product_Name:equals:" + Product_Name + ")");
  2. if(ifnull(grec,List()).size() > 0)
  3. {
  4. rec = grec.get(0);
  5. Unitprice = rec.getJSON("Unit_Price");
  6. Producttype = rec.getJSON("Product_Type");
  7. Productstatus = rec.getJSON("Product_Status");
  8. }
  9. mp = Map();
  10. //use the same variables used in Forms Prefill mapping
  11. mp.put("Unitprice",Unitprice);
  12. mp.put("Producttype",Producttype);
  13. mp.put("Productstatus",Productstatus);
  14. response = Map();
  15. response.put("status_code",200);
  16. response.put("Content-Type","application/json");
  17. response.put("body",mp);
  18. return {"crmAPIResponse":response};
  19. // Please argument the Product_Name in the function as the string.

In the Argument Mapping, You need to Map the field "Product_Name" to search the record as a String


Calling Function using REST API in Zoho CRM:

Once the above Standalone Function has been Saved, We need to create the REST API for the Standalone Function :
  1. Go to Setup > Developer Hub > Functions.
  2. Click the Settings icon for the corresponding function which needs to be made an API.
  3. Click REST API.
  4. The API Name field displays the API name of the function which you must use to invoke it. This API name is system-generated; you cannot modify it.
  5. Enable OAuth2.0 and the API key sliders.
  6. Click Save.


It's  Mandatory to Save the function after generating the REST API Key.

Dynamic Prefill - Webhook configuration in Zoho Forms:

Once you have your form built, Function has been configured in Zoho CRM and the REST API has been generated, Navigate to the Zoho Forms > In your Respective Form builder >  Settings tab >Prefill > Dynamic Prefill - Webhook > Click Configure.

Search Configuration:

The Search Field will be the form field which will be used to retrieve related information from an external service. Select a form field from the dropdown as the Search Field. We need to choose the "Choose the Product" field to search the record in CRM using the Webhook.

Webhook Details:
 

The Webhook URL is the endpoint where your form will send requests to the external service on search. Enter the full URL of the external service to retrieve the data. We need to pass the REST API Key URL from Zoho CRM as mentioned in the Previous Step. 

FuntionName : It's the Name for the Standalone Function from Zoho CRM where the REST API Key has been generated. 

Authorization Type : General

The Record Identifier Key is used as a query parameter to send the value in the Search Field to Zoho CRM.  During a record search, the webhook will include the Record Identifier Key as a query parameter. The value of the Search Field will be sent as the query parameter value. So, The Search Value that we've passed as a String in the Zoho CRM Standalone Function should be Configured here. Product_Name is the string available in the Argument mapping that we've used in the above Standalone Script.

URL parameters will be added as query strings to the URL for sending additional information with the Webhook request. 
We need to Pass the below informations : 
  1. auth_type : apikey
  2. zapikey : [It'll be available in the Zoho CRM - Rest API] Screenshot shared above. 


Test Webhook: 

Once the Webhook has been configured, In this step, you can test the webhook to ensure it retrieves the correct data based on the value entered in the Search Field. Enter a sample value in place of <Search Field's value> and run the test to send the request to Zoho CRM. It is checked if the format of the response received is valid. You will be able to proceed to the next step only if the received response is valid.

Auto-populate field values from Zoho CRM in the Zoho Form using Dynamic Webhook


The next step is to determine which form fields should be pre-populated with the information from the fetched data. To map the form fields that you wish to prefill with data from Zoho CRM.
  1. Add a form field and click the field corresponding to it.
  2. A popup with the JSON response will open. Identify the keys in the JSON response that contain the data you need and select it for the mapping.
  3. Repeat this for all the form fields that you wish to prefill.
  4. Click Save


Results:





Custom Solution Created by Raghu | Zoho Partner Support.

If you need any further clarifications, please don’t hesitate to contact partner-support@zohocorp.com

NotesAdditionally, we kindly ask all "Europe and UK" partners to reach out to partner-support@eu.zohocorp.com.