Insert rows in Subform

Insert rows in Subform

Table of Contents

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> );
ParameterDescription
<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 LoadYes
On ValidateNo
On SuccessNo
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Created or Edited
On LoadYes
On ValidateNo
On SuccessNo
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Edited
On LoadYes
On ValidateNo
On SuccessNo
On User inputYes
On UpdateYes
Subform on add rowYes
Subform on delete rowYes
When a record is Deleted
On ValidateNo
On SuccessNo
Other workflow events
On a scheduled dateNo
During approval processNo
During payment processNo
In a Custom FunctionNo
In an Action item in reportNo

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);

 

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com