Choose where you’d like to start

Break

Overview

The break statement when executed terminates the execution of the current loop and resumes execution of the first statement after the loop. Typically, a break statement is used for an abrupt drop out from the current loop.

Note: Both break and continue Deluge task helps control the for each loop. The difference between them is that the break statement terminates the execution of the loop and the continue statement terminates only the current iteration of the loop.

Syntax

break;

The syntax can be placed within a conditional block. When the condition is met, the current loop is terminated and the immediate next statement after the loop takes the control.

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

The list - colors contains 4 values. In the following example, if the value "Red" is available in the list, the execution of the for loop will be terminated.

 colors = List();
 colors.add("Green");
 colors.add("Red");
 colors.add("Blue");
 colors.add("Teal");
 for each rec in colors
 {
 if(rec == "Red")
 { 
 break;
 }
 info rec;
 }

Returns:
Green

Example 2

Let's assume a collection variable - technicians contains details of different technicians and their availability statuses. To display the first available technician, you can use "break" statement.

technician1 = Collection(); 
technician1.insert("name":"Alberto"); 
technician1.insert("status":"unavailable"); 
 
technician2 = Collection(); 
technician2.insert("name":"Bruno"); 
technician2.insert("status":"available"); 
 
technician3 = Collection(); 
technician3.insert("name":"A3"); 
technician3.insert("status":"available"); 
 
technicians = Collection(); 
technicians.insert(technician1); 
technicians.insert(technician2); 
technicians.insert(technician3); 
 
for each technician in technicians 
{ 
    if(technician.get("status") == "available")  
    { 
        info technician.get("name") + " is available"; 
        break; 
    } 
} 
 //Returns Bruno is available

Related Links

Get Started Now

Execute