conditional_error
Raises an error with a custom message when a specified condition is true. This is useful for adding validation checks within formula expressions to halt execution when data does not meet requirements.
Syntax
conditional_error(condition, message)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| condition | boolean | Yes | The condition to evaluate. If true, the error is raised. |
| message | string | Yes | The error message to display when the condition is true. |
Returns
Type: None
Returns None when the condition is false. Raises an exception when the condition is true.
Examples
Validating a required field:
conditional_error([short_description] == "", "Short description cannot be empty")
Raises an error if the short_description field is empty.
Checking a numeric range:
conditional_error([priority] > 5, concatenate("Invalid priority value: ", [priority]))
Raises an error if the priority value exceeds the allowed maximum.
Ensuring a reference field is populated:
conditional_error([assigned_to] == None, "Record must have an assigned user before migration")
Prevents migration of records that lack an assigned user.
Notes
- When the condition is
false, the function does nothing and returnsNone. - When the condition is
true, execution of the current formula stops and the error message is logged. - This function is useful for enforcing data quality rules during procedure execution.
- The error message can be built dynamically using other functions like
concatenate.
Comments
0 comments
Please sign in to leave a comment.