Saflet101Choice
Choice Routing
In cases where you need to have multiple process flow paths for separate conditions based on a single variable (or literal/script); you can use the Choice ActionStep . In these situations you could us multiple IfThen steps, but the Choice step helps give visual order to the process.
NOTE: The Choice step acts much like the switch operation common in many modern programming languages.
Walkthrough
Download Saflet Used in this Walkthrough
For this walkthrough; you will need to be connected to a SafiServer (see Connection to SafiServer from SafiWorkshop). You will also need to create a Project/Saflet with the Custom Initiator selected as the starting initiator (See: Creating a Project and Saflet)
First, add a Local variable named myActionVar of the type Text and assign it a default value of A:
Next add the following ActionSteps to your work area:
- (1) Choice (found under Logic)
- (3) DebugLog
And connect them like this:
We'll connect the other two DebugLog steps later
Double-click the Choice step to open the edit dialog and set the Value field to the myActionVar (press the edit button(...) and select the variable):
Add a CaseItem by pressing the plus (+) button to the right of the Choices box. In the script tab enter the following:
"A";
Press OK and repeat the process entering the following in the script tab:
"B";
After pressing OK to add; you should the following:
And when you press OK; your workspace should look like this (the Choice step now has two more exit paths):
Now connect the newly formed exit paths to the top two DebugLog steps. Also, set the Message fields in DebugLog steps with the following script (top to bottom):
"the A path was taken";
"the B path was taken";
"the default path was taken";
Save and Publish the Saflet and set it off using the Custom Initiator Launcher
Your Console should look like this:
You can debug this Saflet to get a more granular view of whats happening. You can also change the Initial Value of the myActionVar variable to see the different paths (i.e. try changing it to "B").
SideBar
User Login
Comments (