Iterate Form Rows (for each record)

 

Description

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 1:

for each <row-variable> in <formname> [criteria]

where,

  • 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.
  • row-variable - this variable will hold the data for a single row corresponding to each iteration.

syntax 2:

for each <row-variable> in <formvariable>

where,

  • formvariable : it is the name of the collection variable that contains form data. Read More.

  • row-variable - this variable will hold the data for a single record corresponding to each iteration.

Example

    Visualize a simple HR application. The form 'Employee' has the following fields.

      • Name          -   Name of the Employee
      • Qualification -   Employee Qualification
      • JoinDate      -   Date of joining the company
      • Email          -   Official email id of the employee
      • Team          -  Team name of the employee

     

    We want to send emails individually to each member of a product team say, 'Deluge' team.

    sample 1:

    for each x in Employee [Team == "Deluge"]
    {
            sendmail
            (
                To      : x.Email
                Subject : "Important announcement"
                Message : "Your message goes here"
            )
    } 

    where, x is a row variable

    sample 2:

    employeerecords = Employee [Team == "Deluge"];
    for each x in employeerecords
    {
            sendmail
            (
                To      : x.Email
                Subject : "Important announcement"
                Message : "Your message goes here"
            )
    }

    where,

      • x : row variable
      • employeerecords : It contains the form data

Related Links:

Tips & Tricks - Iterating Records in a Form
Tips & Tricks - How can I use a field value in a form in the To Address of a send mail task, in another form