Adding Subform Rows in Zoho CRM

Here’s a cool bite-sized function for you! We’re gonna show you how to add subform rows on Zoho CRM via Deluge scripting without overwriting existing row(s), no API calls needed!

If you’ve ever Googled this, you would probably find the API documentation on subforms. While this works, it doesn’t explain the parameters needed if you’d like to add additional rows without overwriting the table. Plus, if you’re gonna be executing this function in CRM, the method I’m about to show you is simpler.

If this is helpful, check out our other Zoho training and educational resources! And, for more information about CRM, take a look at our HubSpot and Zoho CRM comparison.

Cool Ideas to Use the Code

Think of subforms as a spreadsheet table where you can store multiple line items on a single CRM record. The ability to add rows to the subform via Deluge creates many possibilities:
  • You can write a function to log the details of every outreach made on a Lead to an “Outreach Log” on a subform
  • If you have a subform on Deals that logs product sales, and another similar subform on Accounts to record every product sold under the Account, you can write a function that adds a line item to the Account subform whenever a line item is added on a subform of any related Deal.

Create a Map for the New Row

Create a map with the subform columns (keys) and the respective values for the new row to add.
				
					updateMap = Map();
updateMap.put("Product","Apples");
updateMap.put("Quantity","50");
updateMap.put("Price","2");
				
			
Note: Please replace the keys with your subform column API names and the values respectively.

Add the Map into a List

Create a map with the subform columns (keys) and the respective values for the new row to add.
				
					updateList = List();
updateList.add(updateMap);
				
			

Add Existing Subform Row(s) to the List

This step will prevent the existing subform row(s) from being overwritten.

  • Access the subform by getting the API name on the record
  • Use a loop to iterate through every row of the subform.
  • For each row, create a map with row ID, and add to the updateList variable.
				
					record = zoho.crm.getRecordById("INSERT_MODULE_API_NAME", "INSERT_RECORD_ID");
subform = record.get("INSERT_SUBFORM_API_NAME");
for each s in subform
{
	updateList.add({"id":s.get("id")});
}
				
			

Update the Subform on CRM

Update the subform on the CRM record with the updateList variable that you have made.

				
					updateCRM = zoho.crm.updateRecord("INSERT_MODULE_API_NAME", "INSERT_RECORD_ID" , {"INSERT_SUBFORM_API_NAME" : updateList});
info updateCRM;
				
			
Click here to copy the scripts. For more Zoho-wizardry, check out our GitHub page.

Contact Us!

Book a free 30-minutes consultation with a Zoho expert or send us an email

Related Resources