How can I iterate a collection of records?

How can I iterate a collection of records?

The for each syntax in Deluge scripting, enables you to conditionally fetch a collection of records and iterate over them. Let us illustrate this with the help of a simple example. The CEO of a company wants to address all the new employees who have joined after certain date say, '10-jun-2007' . We have to mail all these new employees. Lets see how we can achieve this.

1. Form 'Employee' has the following fields: Name, Qualification, EmailID, TeamName, JoinDate 


2. Write 
Form Actions -> on add -> On success script, as given below:

for each x in Employee [JoinDate > '10-Jul-2007']
{
sendmail
(
To : x.EmailID
From : "yourmail@yourdomain.com"
Subject : "Meeting at 6:pm tomorrow"
Message : "As our CEO wants to address the new employees, you are requested to attend the meeting.<br>Thanks"
)
}

Code Explanation

for each x in Employee [JoinDate > '10-Jul-2007'] - Fetch the records from the Employee form with the given criteria and iterate over each record, to send mail to the EmailID of each record. Here 'x' is the instance variable that will represent a single record in each iteration.

sendmail - The deluge function to send mail

x.EmailID - Refers to the emailid of each record

    • Related Articles

    • How to Iterate Records in a Form

      The "Task Management" application illustrates the usage of for each record Deluge statement, to iterate records in a form. The applicationcomprises of the following forms: Staff Details: To store the staff details like name, emailid etc. Task: To ...
    • How to Iterate Records in a Form

      About the application  The "Task Management" application illustrates the usage of for each record Deluge statement, to iterate records in a form. The applicationcomprises of the following forms: Staff Details: To store the staff details like name, ...
    • How can I send mail to particular records using Deluge script?

      You can send mail to specific records in a form by using the sendmail Deluge syntax within a for each deluge statement. Refer the link Fetch a collection of records and iterate over them, for more information.
    • How to view the records that are added today?

      If you want to restrict a View to display today's records,  Click on Edit this application and select your View. Click on Set Criteria -> Restricted Records. Choose "Added Time" for the first drop down and "Today" for the second drop down. Click on ...
    • How can I fetch records within a given range

      To fetch records from a Form within a given range, specify the start index and end index range in the Fetch records task, as shown in the sample code below. Here, the first five records that are sorted by Added_Time field will be fetched from ...