Flow switch

Created by akaBot Support, Modified on Mon, 9 Sep, 2024 at 4:01 PM by akaBot Support

1. Program Name of the Activity

System.Activities.Statements.FlowSwitch

2. Explanation

Studio Version ~2.0.2.0

  • Quick Access: "Toolbox" > "Flowchart" > "Flow Switch"

Studio Version 2.0.3.0~

  • Quick Access: "Toolbox" > "System" > "Flowchart" > "Flow Switch"

This activity is used to split control flow into branches, each executed based on a specified condition. It can only be used within the "Flowchart" activity.
Note: Some wording may vary depending on the version.

3. Properties

Property Item
Property Name
Input Field
Description
Other
TypeArgument
Dropdown Selection
Choose the variable type used for the Case in conditional branching.
Expression
Enter Value (String)
Enter the expression or variable used for the condition.

Display Name
Any string
Reflected in the activity name in the designer panel.

Note: In rare cases, the "Display Name" property may not appear in the properties panel, but you can change the display name in the designer panel directly. (This will be fixed in the future.)

4. How to Use

The "Flow Switch" activity can only be used within the "Flowchart" activity, so you must first place the "Flowchart" activity from "System" > "Flowchart" in the designer panel.

After expanding the "Flowchart" activity by double-clicking it, place the "Flow Switch" activity from "System" > "Flowchart".

Once the "Flow Switch" activity is placed, link it with "Start" and then set up the branching conditions.

How to Link Activities

When hovering over "Start," a small square will appear outside the frame. Click on this small square and, while holding the click, move to the next activity (in this case, "Flow Switch") to display an arrow. Release the click when the arrow reaches the next activity frame.

In this example, we create a workflow that displays a message based on the variable "color" being "red," "blue," or "green."

First, create a variable called "color."


Open the Variables panel by clicking "Variables" at the bottom of the screen and set up the variable as follows:

  • Name: Enter "color"
  • Variable Type: Select "String"
  • Scope: Select "Sequence"
  • Default Value: Enter "red"
    (Be sure to include the quotation marks for the default value)

Next, configure the properties of the "Flow Switch" activity.
Open the properties panel and set the "TypeArgument" property to "String" and the "Expression" property to the variable "color" created earlier.

Note: Changing the "TypeArgument" property automatically updates the prefix numbers displayed on the activity.

Now, place three "Message Box" activities to display messages, as there are three branching conditions (red, blue, and green). Link each "Message Box" with the "Flow Switch" activity using arrows.
Be careful not to accidentally link the activity back to the "Flow Switch," as this will create an infinite loop.


Next, set the cases for the branching.
Click on the "Default" label on the line connecting "Flow Switch" to "Message Box" to open the properties panel.
Uncheck "IsDefaultCase" and set "Case" to "red."

Do the same for "Case 1" and "Case 2," setting them to "blue" and "green," respectively.

Next, configure the messages displayed in the "Message Box" activities.
Double-click on the leftmost "Message Box" activity and set the "Text" property to 
"hello red".

Return to the "Flowchart" and set the text for the middle and right "Message Box" activities to "hello blue" and "hello green" respectively.


Completed Workflow

When executed with the variable color's default value set to "red," running the workflow will display the message "hello red"


Changing the default value of color to "blue" or "green" will change the message accordingly.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article