How to define number of subform rows dynamically using script in Zoho Creator?

22.05.19 01:01 PM - By CreatorScripts

Its important to highlight that this post assumes you are already familiar with proper subform creation in Zoho Creator. If you are not please check out our Master Zoho Creator Subforms course in the url below before implementing this custom function.

https://www.udemy.com/master-zoho-creator-subforms/


That being said let´s jump on to the process in question. We are using a Gym App for testing and the goal is to add Classes to a New Member dinamically so user does not have to add classes everytime.


First, you need to call ( get ) the Member record you are going to be working with. Second, you want to create a Form with the records you want to add. In this case our Main Courses is a predetermined number of classes a member can take. You can update this records , delete them or add more as needed. The custom function will iterate through all these records in order to add them into the corresponding subform.


And last but not least you push ( Add ) the records in the Main Classes form into the subform Classes as shown in the custom function below

Custom Function


void Create.subformrows(int mid)
{
//First Step: To call ( get ) the record in question.
member = Members[ID == input.mid];
info member.ID;
//Second Step: Iterate through the records you want to add to the subform
for each rec in Main_Clasess[ID != null]
{
//Step Three: Insert data into the subform
cla = insert into Clases
[
Added_User=zoho.loginuser
Name=rec.Name
Description=rec.Description
Coaches=rec.Coaches
MemberID=member.ID
];
}
}

CreatorScripts