

How to use "Try" Function
Description
The Try function provides a fallback value when a calculation or operation fails. This is useful for handling errors gracefully in your flows, ensuring that failures do not break the entire process.
How to use:
try(statement, fallback)
statement: The primary operation or calculation to attempt.
fallback: The value to return if the statement fails due to an error.
Output
If the statement executes successfully, the function returns the result of that statement.
If the statement fails (e.g., division by zero, an invalid reference, or a missing value), the function returns the fallback value instead.
Examples
Handling Division by Zero
try(math.div(100, 0), "Div by 0")
Output:
"Div by 0"
Since dividing by zero is not allowed, the function returns the fallback value"Div by 0"
.Successful Calculation
try(math.div(100, 10), "Div by 0")
Output:
10
The division operation succeeds, so the function returns10
instead of the fallback.Providing a Numeric Fallback
try(math.div(100, 0), 100)
Output:
100
The division fails, so instead of breaking the flow, the fallback value100
is returned.
When to Use the "Try" Function
To avoid errors stopping your flow when working with external data or calculations.
To provide default values when an operation may fail, ensuring smooth execution.
To handle missing or invalid inputs without disrupting the automation.
By using Try, you can make your flows more resilient and prevent unnecessary failures in data processing!