Iterate Records in a Picklist
The For each list value Deluge statement allows you to iterate through multiple list values in a picklist. The sample application “Task Management” illustrates the usage of the for each list value deluge task. The application comprises of the following three forms:
- Staff Details: To enter the Name and E-mail id of the staff.
- Tasks: To enter the list of tasks and its description.
- Assign Task: To assign one or more tasks to a staff on any specific date, where tasks and staff are lookup fields imported from the respective forms. When a task is assigned, an email is sent to the staff informing him about the list of tasks assigned. This is achieved using the for each list value deluge task that can iterate multiple list values within each record.
for each Tasks_Assigned r in Assign_Task[(Staff == input.Staff && Assigned_Date == input.Assigned_Date)]
temp = temp + r.Task + "<br>";
rec = Staff_Details[Staff_Name == input.Staff];
subject:"Subject of the email"
message:"The following tasks are assigned to you: <br>" + temp
- A variable named temp is declared to store the values of the tasks assigned. Initially the value of the variable temp is set to NULL. The deluge task Set Variable is used to declare the temp variable.
- for each list value task mentioned in the above code, iterates through mulitple values in the Task_Assigned look up field of the Assign Task form.
- criteria fetches the records of the staff name and Assigned date same as the input staff name and date.
- r is the collection variable that holds the data corresponding to each iteration.
- the "temp" variable is appended with each task value.
- r.Task will fetch the task from the related Tasks form.
- The Fetch Record deluge task in the above code is used to fetch the records from Staff_details Form that matches the given criteria and store it in a variable named rec.
To : rec.Email_Id
From : zoho.adminuserid
Subject : "Subject of the email"
Message : "The following tasks are assigned to you: <br>" + temp
The Send Mail task mentioned above is called to send an email to the Email ID of the staff. Here,
- rec.Email_Id will fetch the staff email id from the rec variable.
- Temp contains the list of tasks assigned to the staff.
Learn how to install the application to your account - click here.