A subform is a form within a form. The primary form is called the main form, and the form that is inserted in the main form is called the subform. Subforms are generally used to show data from tables that have a one-to-many relationship. For example you would use a subform if you wanted to display an order with the order details. In this case, the order information would display on the "main" form and the order details would display on the subform. The data in the order table is the "one" side of the relationship. The data in the Item table is the "many" side of the relationship — each order can have more than one item. The sample application "Order Management" illustrates the subform feature.
Zoho Creator supports the "SubForm" field type using which you can insert a subform into your mainform. Please find the steps given below to create a subform.
Create a lookup in the subform and relate it to the parent form. Once the lookup field is created in the child form, that field can be used as relationship field between the two forms. When adding the lookup, select the existing subform relation and pick the ID field, as shown in the image attached.
Select the subform report from the Reports tab, click on "Column Properties" and select the lookup field created above and click on "Link " button, to create a link to the main form data.
You can set the "Default Rows" and "Maximum Rows" for a subform field type from the "Appearence" section under the field properties tab of the subform field.
To export main form data with subform,
For example : https://creatorexport.zoho.com/sampleapps/export-data/xls/Main_Form_View/exportDisplayData=false
The Subform name represents the entire collection of records in a subform. ID value will be available only after the subform record gets persisted in the database. The expressions <collection>.<subform_name> will return another collection. A row is a pre-defined variable available in on add row, on delete row and on user input action of a subform field. You can access, update and dynamically append or clear values of subform field using a row.
The following field action script is supported for subform field types, as shown below.
The following Field Action Script is supported for all the fields within the Subform.
You can add items to a picklist in a subform using the UI.append task. Refer this help topic for syntax and sample code.
Refer this kbase topic to add items to a picklist in a subform based on selection in main form.
You can Hide and Disable subform fields in theon load action of main form andon user input action of main form fields.The syntax for hiding and disabling subform field is as follows:
hide <sub form name>.<field name>;
show <sub form name>.<field name>;
enable <sub form name>.<field name>;
disable <sub form name>.<field name>;
The above tasks when executed perform the operation on entire column. For ex, when hide task is applied on subform field, it hides the entire column in the subform grid.
You can use the following script to populate a field in the subform with the value of the field in the main form. In the "On Add Row" task of the subform, give the script as
row.SubFormField = input.FormField;