- 04 Apr 2025
- 1 Minute to read
- Print
- PDF
If Control Statements
- Updated on 04 Apr 2025
- 1 Minute to read
- Print
- PDF
If Control Statements
An IF control statement enables logical branching in Integration Hub recipes, guiding the recipe’s execution based on defined conditions. This section covers effective management of conditional logic and outlines the flow of conditional branches.
Managing Conditional Logic with IF Control Statements
The IF control statement sequentially evaluates each branch and stops when a condition is met:
IF: The initial condition is checked first.
ELSE IF: If the IF condition is false, this condition is evaluated. Multiple ELSE IF conditions can be added in sequence.
ELSE: Executes only if none of the previous conditions are met.
Figure: If condition
This process ensures that only one branch is executed, preventing overlaps or unintended actions.
Overlapping Conditions
Overlapping conditions can cause multiple logic blocks to execute simultaneously, leading to unintended behavior. The IF-ELSE IF structure ensures that only one logic block runs, preventing execution conflicts.
Revising Conditions
Previously, adding or removing conditions required extensive restructuring of IF-ELSE logic, increasing the risk of errors. With IF control statements, conditions can be modified smoothly, preserving the integrity of the recipe.
Improving Readability
While nested IF conditions do not necessarily slow down execution, they can reduce clarity and make debugging more challenging. Using IF-ELSE IF structures result in cleaner, more manageable recipes, avoiding the complexity of deeply nested conditions.
Repeat Control Statements (Loops)
Repeat control statements enable the repetition of a set of steps based on specific criteria. Integration Hub provides two types of Repeat control statements:
Repeat While
Executes one or more actions repeatedly while a specified condition remains true. The loop automatically stops once the condition is no longer met.
Example: Retrieving the next page of Google Drive search results until there are no more pages left.
Repeat For Each
Executes one or more actions for every item in a list. The loop ends when all items have been processed.
Example: Downloading each file from a list of Google Drive search results.
Note
By default, the Repeat For Each control statement processes list items one at a time or in batches.
The following diagrams illustrate the logic of Repeat While and Repeat For Each loops.
Figure: Repeat while loop
Figure: Repeat for each loop