Subform Updates

What are subforms?

Explaining plainly, a subform is simply a form within a form. Since all the data stored within your CRM is inter-dependent, there is a need to associate multiple items/records to a single record. To learn more about subforms, click here. This feature is available only in the Enterprise edition.

For example, let's take a situation where you have a client "SHIELD Health Care", and they procure the products "Syringes", "Bandages" and "Gloves" from you. The information about their company would be in Accounts module and the products in Products module. You can create a subform in the Accounts module which can contain the list of products involved in the deal.


Business scenario:

Subforms are quite an advancement in the Zoho CRM experience. Simply because of the fact that it solves the problem of establishing a one-to-many relationship with data in your CRM, in which many secondary items are associated to a single primary record.

This function is about using the subform feature. You can associate multiple records with a single record and also have them updated. In this function, we have created a subform in a Deal record which gets information from records in the Products module.


Getting started with the function:

  1. Go to Setup > Developer Space > Functions > + Create New Function.
  2. Select Automation as Function type and click Next.
  3. Provide a name for the function. Add a description(optional).
  4. Copy the code given below.
  5. Click Edit Arguments.
  6. Enter the name as dealId and select the type as Int.
  7. Click Save&Execute Script.
  8. Click Save.

The Code:

dealDetails = zoho.crm.getRecordById("Deals", input.dealId.toLong());
//info leadDetails;
subform1 = ifnull(dealDetails.get("Subform_1"),"").toMap();
productId = ifnull(subform1.get("Product"),"").get("id");
productDetails = zoho.crm.getRecordById("Products",productId.toLong());
unitprice = ifnull(productDetails.get("Unit_Price"),"0.0").toDecimal();
subform1id = ifnull(subform1.get("id"),"");
subform = Map();
sub_forms = List();
parammap = Map();
update = zoho.crm.update("Deals",dealId.toLong(),parammap);
info parammap;
info update;


  • The above code works only for API V2.0 and not the previous version.
  • Use this code to update a subform in any module, which has records from other modules as a lookup.

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips