Insert rows in Subform
Note: This task is applicable only to Zoho Creator.
Overview
This task is used to dynamically insert rows into a subform.
Syntax
// declaring the row
<row1> = <mainForm_linkName>.<subForm_linkName>();
// assigning values for various subform fields in the row
<row1>.<field_linkName> = <value>;
<row1>.<field_linkName> = <value>;
// declaring another row (declare as many rows as required)
<row2> = <mainForm_linkName>.<subForm_linkName>();
// assigning values for various subform fields in the row
<row2>.<field_linkName> = <value>;
<row2>.<field_linkName> = <value>;
// declare a variable to hold the collection of rows
<variable> = Collection();
<variable>.insert( <row1>, <row2> );
// insert the rows into the subform through the variable
input.<subForm_linkName>.insert( <variable> );
<row1> = <mainForm_linkName>.<subForm_linkName>();
// assigning values for various subform fields in the row
<row1>.<field_linkName> = <value>;
<row1>.<field_linkName> = <value>;
// declaring another row (declare as many rows as required)
<row2> = <mainForm_linkName>.<subForm_linkName>();
// assigning values for various subform fields in the row
<row2>.<field_linkName> = <value>;
<row2>.<field_linkName> = <value>;
// declare a variable to hold the collection of rows
<variable> = Collection();
<variable>.insert( <row1>, <row2> );
// insert the rows into the subform through the variable
input.<subForm_linkName>.insert( <variable> );
Parameter | Description |
---|---|
<rowN> | Variable to represent an individual row |
<mainForm_linkName> | Link name of the parent form in which the subform exists |
<subForm_linkName> | Link name of the subform in which the rows will be added |
<field_linkName> | Link name of the subform field |
<value> | Value that will be assigned to the subform field |
<variable> | Variable to hold a collection of rows |
Note:
- This task can be used to assign values to subform fields while adding or updating records using Deluge scripts. For example, the following snippet assigns values to subform fields while using the add record task:<row1> = <mainForm_linkName>.<subForm_linkName>();
<row1>.<field_linkName> = <value>;
<rows> = collection();
<rows>.insert(<row1>);
<variable> = insert into <mainForm_linkName>
[
<subForm_linkName> = <rows>
]; - If the script execution encounters an issue while the process of inserting rows is underway, the behavior of this task will be as follows:
- Script written in On Load and On User Input: Rows that have been inserted will remain so, and the remaining rows will not be inserted
- Script written in On Validate and On Success: None of the rows will be inserted.
This task can be used in the following events
When a record is Created | ||
On Load | Yes | |
On Validate | No | |
On Success | No | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Created or Edited | ||
On Load | Yes | |
On Validate | No | |
On Success | No | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Edited | ||
On Load | Yes | |
On Validate | No | |
On Success | No | |
On User input | Yes | |
On Update | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Deleted | ||
On Validate | No | |
On Success | No | |
Other workflow events | ||
On a scheduled date | No | |
During approval process | No | |
During payment process | No | |
In a Custom Function | No | |
In an Action item in report | No |
Example
1) Let's say we have a Products form that has a subform field Items. The subform has fields "Item Name", "Quantity", and "Price". We need to populate the subform fields "Item Name" and "Quantity" with values "Laptop" and 1 respectively. The following snippet (written in the On Load section) can be used in this scenario:
row1 = Products.Items();
row1.Item_Name = "Laptop";
row1.Quantity = 1;
input.Items.insert(row1);
row1.Item_Name = "Laptop";
row1.Quantity = 1;
input.Items.insert(row1);