Continue
Table of Contents
Overview
The continue statement skips a particular iteration within a loop based on specified condition and continues with the iteration process. Typically used instead of using conditional statements to skip/ignore certain portion of a loop.
Syntax
continue;
The syntax can be placed within the loop after a conditional statement. When the condition is met, the current iteration is skipped while the loop continues.
This task can be used in the following events
When a record is Created | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Created or Edited | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Edited | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Deleted | ||
On Validate | Yes | |
On Success | Yes | |
Other workflow events | ||
On a scheduled date | Yes | |
During approval process | Yes | |
During payment process | Yes | |
In a Custom Function | Yes | |
In an Action item in report | Yes |
Example 1
The list - colors contains 4 values. In the following example, when the value "Red" is encountered in the list, the execution of the current iteration is skipped.
colors = List(); colors.add("Green"); colors.add("Red"); colors.add("Blue"); colors.add("Red"); colors.add("Teal"); for each rec in colors { if(rec == "Red") { continue; } info rec; }
Returns:
Green
Blue
Teal
Example 2
Let us say a list variable orders contains the details of orders placed such as: order ID, order status, and customer email. To send a mail to every order except for the orders with the status - "Delivered", we can use the "continue" statement as shown below:
order1 = Collection(); order1.insert("id":"1000"); order1.insert("status":"Approved"); order1.insert("customer-email":"james@zylker.com"); order2 = Collection(); order2.insert("id":"1001"); order2.insert("status":"Pending"); order2.insert("customer-email":"august@zylker.com"); order3 = Collection(); order3.insert("id":"1002"); order3.insert("status":"Delivered"); order3.insert("customer-email":"betty@zylker.com"); orders = Collection(); orders.insert(order1); orders.insert(order2); orders.insert(order3); for each order in orders { if(order.get("status")=="Delivered") { continue; } sendmail [ from:zoho.adminuserid to:order.get("customer-email") subject:"Order Delay Notice" message:"Due to the current measures to protect the safety of our distribution center employees, please expect delays in processing and delivering your order. We apologize for the inconvenience." ] }