Zoho CRM offers robust customization capabilities, including the ability to insert and manage subforms. Subforms in Zoho CRM allow you to include multiple line items (e.g., product details, order information) within a single form. Using Deluge scripting, Zoho’s custom scripting language, you can automate the process of inserting data into these subforms.
In this guide, I’ll walk you through how to insert subform in zoho crm using deluge scripting.
Step-by-Step Guide to how to insert subform in zoho crm using deluge
1. Understanding Subforms in Zoho CRM
Before jumping into Deluge, it’s essential to understand how subforms work in Zoho CRM. A subform is essentially a table that resides within a parent module. For example, in a “Deals” module, you might want to add a subform to track multiple “Product Items” related to that deal.
Subforms can contain multiple fields, and each row represents a separate record within that subform. With Deluge, we can script inserting, updating, or retrieving these records dynamically.
2. Creating the Subform in Zoho CRM
First, ensure that you have created a subform in the module where you want to insert data. Follow these steps:
- Go to Setup > Customization > Modules and Fields.
- Select the desired module (e.g., Deals).
- In the layout editor, drag and drop the Subform component to the desired section of the layout.
- Define the subform’s fields (e.g., Product Name, Quantity, Price).
- Save the module.
Once the subform is created, you can use Deluge to insert data into it programmatically.
3. Writing Deluge Script to how to insert subform in zoho crm using deluge
Here’s an example of how to insert subform in zoho crm using deluge. Let’s assume the parent module is Deals, and the subform within this module is Product Items with fields such as Product Name and Quantity.
Explanation of the Script:
- Fetching the Parent Record:
- You’ll need the record ID of the parent (in this case, a “Deal” record) where you want to how to insert subform in zoho crm using deluge.
- You can fetch this record either by querying it or using a known record ID (
dealId
in this example).
- Creating Maps for Subform Data:
- We create maps (
product_item1
,product_item2
) to represent each row in the subform. - Each map holds the field names as keys (e.g.,
"Product_Name"
,"Quantity"
) and their corresponding values.
- We create maps (
- Storing Subform Entries in a List:
- We then add these maps to a list (
product_items_list
), which represents all rows of the subform.
- We then add these maps to a list (
- Updating the Parent Record:
- The subform entries are added as part of the parent record (
Deals
in this case) by updating the record throughzoho.crm.updateRecord()
API. - The key
"Product_Items"
corresponds to the subform name, and its value is the list containing the rows for the subform.
- The subform entries are added as part of the parent record (
- Displaying the Result:
- The
updateResult
will give a success or failure response, showing whether the data was inserted correctly.
- The
4. Testing the Script
- You can test this Deluge script in Zoho CRM by creating a custom function.
- Navigate to Setup > Developer Space > Functions.
- Create a new function and paste the Deluge script.
- Run the function with a sample record ID to see if the subform data is correctly inserted into the parent record.
5. Handling Errors and Debugging
Deluge scripts can fail due to various reasons such as incorrect field names, invalid record IDs, or permission issues. Here are a few tips for handling errors:
- Always check the subform field API names (you can find these in the module customization section).
- Use
info
orlog
statements to track the output of each step in the script, especially for debugging. - Make sure the record ID you are updating exists in the CRM.
6. Bonus: Retrieving Subform Data Using Deluge
In some cases, you may need to retrieve subform data from a parent record. Here’s a quick example of how you can do that:
This script fetches the subform data from a “Deal” record and logs each product with its quantity.
Conclusion
How to insert subform in zoho crm using deluge opens up a wide range of automation possibilities. Whether you’re automating product line entries in Deals, managing invoices with multiple items, or simply organizing records more efficiently, Deluge scripting provides a flexible and powerful way to manage subforms.
By understanding the structure of your CRM modules and using Deluge’s built-in functions like zoho.crm.updateRecord()
, you can quickly insert and manage subform data, saving you time and improving data consistency.
FAQs
- What is Deluge in Zoho CRM?
Deluge is Zoho’s scripting language used for automation and customization within Zoho CRM. - Can I insert multiple rows into a subform at once using Deluge?
Yes, by creating a list of maps where each map represents a row, you can insert multiple rows into a subform in a single operation. - How do I find the subform’s field API names?
Go to the module customization section in Zoho CRM, and you can find the API names of all fields including subform fields. - What if the subform insert fails?
You can useinfo
orlog
statements in your Deluge script to check where the failure occurred and inspect the response for errors. - Can I use Deluge to update subform data?
Yes, Deluge can be used to update existing subform data. You can fetch the record, modify the subform entries, and then update the parent record with the modified subform list.
For more information about the how to insert subform in zoho crm using deluge, visit this link.
If you want to Free Trail Zoho, click on this link.