Creator Help

For each Record in Form

Iterate Form Rows (for each record)

Unlike other languages which supports iteration based on numerical values, say iterate 10 times, deluge supports only data driven iterators that are purely based on form data. You can iterate through all the rows in the form or through selected rows based on the given criteria.

Syntax

Syntax:

for each <row-variable> in <formname> [<criteria>] sort by <field> range from <x> to <y>;

where,
Row-variable - This variable will hold the data for a single row corresponding to each iteration.
Formname - Name of the form whose data has to be iterated one by one.
Criteria - In most of the cases, you would like to conditionaly fetch the data. You can specify your criteria for fetching the form data here. It is an optional parameter.
sort by <field> allows you to sort the iterated records based on the specified <field>. It is an optional parameter.
range from <x> to <y> enables you to limit the records iterated within the start index (x) and end index (y). If range is not specified, all the records in the form that satisfy the given criteria, will be iterated in an ascending order. To iterate the records in descending order, replace range from <x> to <y> with desc.

Example

The Task Management application illustrates the usage of for each deluge task to iterate records in a form. The application consist of 3 forms.

  • Staff details - To store the Name, Email Id and Module of the staff.
  • Tasks - To store the Task Name and the Description about the Task.
  • Assign Task - To assign one or more task to the staff member. In this form, the drop-down field staff is a lookup to Staff Name field in the staff details form and Task Assigned field is the lookup of Task field in the Tasks form.

In the Task management application, the task is to send mail to each staff belonging to a specific module say "Scripting". To perform this action, we have to add the deluge script to WorkFlow --> On Add --> On Success section of the Staff Details form. The sample script mentioned below will iterate through each staff record in the Staff Details form who belong to a Scripting module and send mail to their email id with the specified message.

for each r in Staff_Details[Module == "Scripting"]
{
SendMail
[
From : zoho.adminuserid
To : r.Email_Id
Subject : "Meeting"
Message : "You are requested to attend the meeting on 22/01/2008, 3 p.m at the pacific hall"
]
}

Code Explanation

for each r in Staff_Details[Module == "Scripting"]

The code mentioned above iterates through each record in the Staff Details form whose module name is “Scripting” where,

  • r is the name of the variable that will hold the data (Staff Name) corresponding to each iteration.

SendMail
[
From : zoho.adminuserid
To : r.Email_Id
Subject : "Meeting"
Message : "You are requested to attend the meeting on 22/01/2008, 3 p.m at the pacific hall"
]

The sendmail function mentioned above is used to send an email to the staff Email Id. Here, r.Email_Id, will fetch the email id from the variable r which holds each iteration of a record.

Install the Application

To install the application,

  1. Download the script file (.ds file)
  2. Install the application to your account. Click here to learn how to install using the script file (.ds file)

Top