You are currently viewing How To Insert Subform in Zoho CRM using Deluge​?

How To Insert Subform in Zoho CRM using Deluge​?

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:

  1. Go to Setup > Customization > Modules and Fields.
  2. Select the desired module (e.g., Deals).
  3. In the layout editor, drag and drop the Subform component to the desired section of the layout.
  4. Define the subform’s fields (e.g., Product Name, Quantity, Price).
  5. 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.

deluge
// Fetching the Deal record where we want to how to insert subform in zoho crm using deluge​ dealId = "123456789"; // Replace with the actual Deal record ID

// Creating a map to hold the subform details
product_item1 = Map();
product_item1.put("Product_Name", "Product A");
product_item1.put("Quantity", 10);

// Creating another map for another product in the subform
product_item2 = Map();
product_item2.put("Product_Name", "Product B");
product_item2.put("Quantity", 5);

// Creating a list to store the subform entries (multiple products)
product_items_list = List();
product_items_list.add(product_item1);
product_items_list.add(product_item2);

// Preparing the parent Deal record for updating with subform data
update_deal = Map();
update_deal.put("Product_Items", product_items_list);

// Updating the Deal record with subform entries
updateResult = zoho.crm.updateRecord("Deals", dealId, update_deal);

info updateResult; // Shows the result of the operation

Explanation of the Script:

  1. 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).
  2. 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.
  3. Storing Subform Entries in a List:
    • We then add these maps to a list (product_items_list), which represents all rows of the subform.
  4. Updating the Parent Record:
    • The subform entries are added as part of the parent record (Deals in this case) by updating the record through zoho.crm.updateRecord() API.
    • The key "Product_Items" corresponds to the subform name, and its value is the list containing the rows for the subform.
  5. Displaying the Result:
    • The updateResult will give a success or failure response, showing whether the data was inserted correctly.

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 or log 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:

deluge
// Fetching a Deal record
dealId = "123456789"; // Replace with actual Deal record ID
dealRecord = zoho.crm.getRecordById("Deals", dealId);

// Extracting subform data
if (dealRecord.containsKey("Product_Items"))
{
productItems = dealRecord.get("Product_Items");
for each item in productItems
{
productName = item.get("Product_Name");
quantity = item.get("Quantity");
info "Product: " + productName + ", Quantity: " + quantity;
}
}

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

  1. What is Deluge in Zoho CRM?
    Deluge is Zoho’s scripting language used for automation and customization within Zoho CRM.
  2. 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.
  3. 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.
  4. What if the subform insert fails?
    You can use info or log statements in your Deluge script to check where the failure occurred and inspect the response for errors.
  5. 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.

Yasir Baig

My name is Mirza Yasir Baig. As an experienced content writer and web developer, I specialize in creating impactful digital experiences. With expertise in WordPress programming and the MERN stack, I have built and managed various web platforms, including the different a dedicated resource for both Pakistani and international students seeking quality courses and training programs. My work is driven by a passion for education and technology, ensuring that content is not only engaging but also optimized for search engines (SEO) to reach a wider audience.

Leave a Reply