Skip to main content

While

System.Activities.Statements.While

The "While" activity in AutomatR is a control flow activity that allows you to repeatedly execute a sequence of activities while a specified condition is true. It is similar to the "Do While" activity, providing a looping structure within workflows where the activities inside the loop are executed as long as the specified condition remains true.

Properties

NameDescription
Misc
ConditionSpecifies the condition that is evaluated before each iteration of the loop. As long as the condition evaluates to true, the activities inside the "While" loop will be executed. The loop continues until the condition becomes false. Boolean variables or expressions that result in a boolean value. The condition determines whether the loop continues or exits.
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 "While" activity onto the workflow.
  2. In the "Condition" property, define the condition that needs to be true for the loop to continue executing.
  3. Place the activities that you want to repeat inside the "While" activity.

Example: Consider an example where the "While" activity is used to simulate a countdown:

While:
Display Name: "Countdown Loop"
Condition: count > 0
// The loop continues as long as the count is greater than 0
Sequence:
Log Message: "Countdown: " + count
Assign: count = count - 1
// Decrement the count for the next iteration

In this example, the "While" loop continues to execute as long as the condition (count > 0) is true. The sequence of activities inside the loop logs the current countdown value, decrements the count, and repeats until the count reaches 0.

The "While" activity is valuable for scenarios where you need to repeat a set of actions based on a condition, providing a flexible and efficient way to implement looping logic in your AutomatR workflows.