The Conditional Statement action will branch between two action sets based on the result of a condition.
In the above image, the conditional statement tests to see if the Screen Active Record ID has been set.
- If the Screen Active Record ID is set, then the action underneath the If...then is completed. In this case, the delete button is shown.
- If the Screen Active Record ID is not set, then the action underneath the Else is completed. Here, the delete button is hidden.
As a side note, see how useful internal notes are? They are the text in grey underneath the actions. Even though the actions are exactly the same, the internal notes tells how they are configured.
To reiterate, the actions will branch and take a different path depending on the result of the condition. When one action is run, the other is ignored. The above can also be represented as such:
Furthermore, although only one action is being shown as a result of the condition, you aren't restricted to just one. You can have multiple actions within each branch.
Conditional statements will be familiar to those of you with a programming background as an "If / Else" statement.
Step 1: Add Your Conditions
Before the conditional statement can branch between either of the two actions sets, you will need to set up the condition. This will be done using the Criteria Builder.
A condition will result in one of two values: Yes or No (Or True and False).
If the condition results in Yes, then all the actions embedded within If..Then will run.
If the condition results in No, then all the actions embedded within Else will run.
Step 2: Add your Actions
If you examine the image above, you will see a blue line that encloses the conditional statement. Actions are embedded within one of two sections inside the conditional statement. As a reminder:
- If...then: actions embedded here will only run if the condition resolves to true.
- Else: actions embedded here will only run if the condition resolves to false.
If you want your actions to be part of the conditional statement, it must be enclosed by the conditional statement. However, it is easy, for example, to accidentally drag an action outside of the Else section when you are meaning to put it inside.
In the below image, the Show / Hide Controls action (which shows the delete button) is properly within the If...then section. However, the last action is not part of the conditional statement.
There are two ways to tell the last action is not part of the else statement:
- It is not indented.
- It is not enclosed by the blue bracket line.
To make sure an action is part of the conditional statement and you don't wish to rely on your mouse dragging target skills, you can add an action directly within the conditional statement.
When you hover over either of the two, a plus sign appears and allows you to add an embedded action.
If you delete the Conditional Statement, all the actions embedded within will also be deleted.