Choose where you’d like to start

For each element

Overview

The for each element deluge task iterates through all the elements present in a list, comma-separated text, or a CSV file.

Syntax

for each <elementVariable> in <variable>
 {
 }
ParameterDescription
<elementVariable>

Variable to hold an element for each iteration.

You can specify any variable name here, without having to declare it initially.

After the iteration, this variable will hold the last element in the list.

<variable>

The variable containing the elements which will be iterated.

Supported data types:

  • List
  • CSV file

Note: The size of the input CSV file cannot be more than 2MB.

This task can be used in the following events

When a record is Created
On LoadYes
On ValidateYes
On SuccessYes
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Created or Edited
On LoadYes
On ValidateYes
On SuccessYes
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Edited
On LoadYes
On ValidateYes
On SuccessYes
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Deleted
On ValidateYes
On SuccessYes
Other workflow events
On a scheduled dateYes
During approval processYes
During payment processYes
In a Custom FunctionYes
In an Action item in reportYes

Example 1: Iterate through a list

The following example displays all the element present in the list - numbers

//Create a list
numbers = {"One", "Two", "Three"};
//Iterate through each element of the list using for each
for each item in numbers
{
info item;
}

Example 2: Send mail for every iteration

In the following example, the code snippet iterates through each team in the list and executes the send mail task for each iteration. "Employees" is a form with "Team" and "EmailID" fields.

//Create list to hold teams
teamList = {"Zoho Creator", "Zoho CRM"};

//Iterate through the list using for each task
for each temp in teamList
{
//Send mails to every team from the list using the sendMail task
sendMail
[
from: zoho.adminuserid
to: Employees[Team = temp].EmailID.getall();
Subject: "Working day for "+temp
Message: "Coming Saturday will be a working day"
];
}

Example 3: Iterate values of a CSV file

//Download a Zip file using invokeUrl task
csv_file_zip = invokeurl
[
url: "https://www.stats.govt.nz/assets/Uploads/Business-financial-data/Business-financial-data-June-2021-quarter/Download-data/wholesale-trade-survey-june-2021-quarter-csv.zip"
type: GET
];

//Extract the csv file from the downloaded zip file
csv_file = csv_file_zip.extract().get("wholesale-trade-survey-jun-2021-quarter-csv.csv");

//Iterate values of the extracted CSV file
for each val in csv_file
{
info val;
}

Related Links

Get Started Now

Execute