"If" activity

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

1. Program Name of the Activity

System.Activities.Statements.If

2. Explanation

  • Studio Version ~2.0.2.0
    Quick Access: "Toolbox" > "Control Flow" > "If"
  • Studio Version 2.0.3.0~
    Quick Access: "Toolbox" > "System" > "Control Flow" > "If"

This activity is used when you want to branch the processing in a workflow based on specific conditions.

3. Properties

Property Item
Property Name
Input Field
Description
Other
Public
Checkbox
If checked, variables and arguments within the activity are logged to a file and pushed to the Center. For details, refer to "Public Property."
Condition
Enter Value (Boolean)
Enter the condition for branching processing (Enter a VB expression).

Display Name
Enter Value (String)
Reflected in the activity name in the Designer panel.

4. How to Use

From the Activity Panel, place the "If" activity.

In the diagram below, configure each field as follows:

  1. Condition: Enter the condition for branching processing.
  2. Then: Place the activity to be performed if the condition is True.
  3. Else: Place the activity to be performed if the condition is False.

Example: Display a dialog asking for the capital of Vietnam, and change the message in the Message Box depending on whether the entered answer is "Ha Noi"

First, place the "Input Dialog" activity above the "If" activity.

In the Input Dialog's "Input > Title" property, enter "Which is the capital of Vietnam", and in the "Output > Result" property, set an Object type variable called answer.
For more details on setting variables, refer to "Creating Variables."

Set the "Condition" field in the "If" activity to answer.ToString = "Ha Noi". (You can also write it as "Ha Noi" = answer.ToString, which has the same meaning.)

In the Then field, place a "Message Box" and set the "Input > Text" property to "true", and the "Input > Buttons" property to "Ok."

In the Else field, place another "Message Box" and set the "Input > Text" property to "false", and the "Input > Buttons" property to "Ok."

After completing all settings, it should look like this:

When executed, the following dialog appears first:

If you enter "Ha Noi" and click the "OK" button, the message "True" is displayed.

On the other hand, if you enter anything other than "Ha Noi" and click the button, the message "False" is displayed.

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