I’ve previously built processes that use boolean values to confirm which path the process should go towards when an error is encountered. After holding a QA Review with one of the senior developers on the team he pointed out that using Nested If Statements is messy and to use a switch activity to manage all the values and paths.
I’ve used the Switch Activity in the past, mainly with numerical values but I have not used it for boolean values. I’ve noticed though that only one boolean expression can be assigned to a switch activity resulting in only 3 cases (Default, True or False).
I was wondering if there was a way to use 1 switch activity to deal with multiple booleans?
I’ve attached below how the process currently looks with the nested if statements.
Each of your Booleans are a different expression.
You have 2 choices I think. You can migrate your logic to a Flow chart and use Decisions instead of nested If activities (this can still be messy sometimes), OR place all your booleans into an expression that returns a number or string.
Nested Decisions that all use the same steps if TRUE would look like this:
I tried the bottom recommendation for using the multiple boolean values in a switch activity to no avail. The process always proceeds down the default path which currently provides a generic error handling message, rather than one of the other cases which logs what the error is and provides more context.
I was wondering how the logic works that you’ve outlined in the the switch explain above. Have you linked a boolean value equaling true to a string value to use in the switch case? If so what would the opposite be? Meaning if I wanted a boolean to be false before going down a specified case path in the switch activity.
I’ve realised that instead of using a boolean value as a flagger I can set a variable (strError) with a differing value depending on the error that’s been encountered. From there I can set that value as the expression in the switch activity and set the necessary case sequences.