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 it has, then it will show the delete button. If it hasn't (the else part) then it will hide the delete button. As a side note, see how usefulness internal notes are?
Conditional statements will be familiar to those of you with a programming background as an "If / Else" statement. It means you're asking Method to take a particular course of action (one action set) if certain conditions are met. Otherwise (else), it will follow a different course (a second action set).
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 conditiond. 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 condiion 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.