Skip to main content

If

System.Activities.Statements.If

The "If" activity in AutomatR is a conditional control flow activity that allows you to implement decision-making logic within your automation workflows. It evaluates a specified condition and executes a set of activities based on whether the condition is true or false. The "If" activity is fundamental for creating workflows with branching paths, enabling different actions to be taken depending on the outcome of a condition.

Properties

NameDescription
Misc
ConditionSpecifies the condition to be evaluated. The activities inside the "Then" or "Else" block are executed based on whether this condition is true or false. Boolean variables or expressions that result in a boolean value. The condition determines which branch of the "If" activity will be executed.
Display NameThe display name of the activity. A display name is automatically generated when you indicate a target.

How to use:

  1. Drag and drop the "If" activity onto the workflow.
  2. In the "Condition" property, define the condition that determines which branch of the "If" activity should be executed.
  3. Place the activities to be executed when the condition is true inside the "Then" block.
  4. Optionally, place the activities to be executed when the condition is false inside the "Else" block.

Example: Consider an example where the "If" activity is used to check whether a given number is even or odd:

If:
Display Name: "Check Even or Odd"
Condition: number % 2 = 0
// The condition checks whether the number is divisible by 2 (even)
Then:
Log Message: "The number is even."
Else:
Log Message: "The number is odd."

In this example, the "If" activity checks whether the number is divisible by 2 (even). If the condition is true, the "Then" block is executed, logging a message that the number is even. If the condition is false, the "Else" block is executed, logging a message that the number is odd.

The "If" activity is crucial for introducing decision-making capabilities into workflows, allowing automation developers to create dynamic and flexible processes based on specific conditions.