Skip to main content

Do While

System.Activities.Statements.DoWhile

The "Do 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. This structure is fundamental for implementing loops in workflows, enabling automation developers to iteratively perform actions until a certain condition is no longer met.

Properties

NameDescription
Misc
ConditionSpecifies the condition that determines whether the loop should continue executing. As long as the condition evaluates to true, the activities within the "Do While" loop will be executed repeatedly. Boolean variables or expressions that result in a boolean value. The loop continues as long as the condition evaluates to true.
Display NameThe display name of the activity. A display name is automatically generated when you indicate a target.
ToSpecifies the variable or property to which the value will be assigned. You can select an existing variable or create a new one directly from the "To" property. Variables of various types (int, string, bool, etc.) or properties of specific activities. You can also create new variables by clicking the ellipsis (...) and defining the variable in the Variable Manager.
ValueSpecifies the value to be assigned to the variable or property defined in the "To" property. This value can be a constant, a result of an expression, or a value stored in another variable. Variables of various types, constants, or expressions. You can use existing variables, literal values (e.g., "Hello, World!"), or expressions that evaluate to the desired value.

How to use:

  1. Drag and drop the "Do 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 "Do While" activity.

Example: Consider an example where the "Do While" activity is used to iterate through a list of items and perform an action for each item:

Do While:
Display Name: "Process Items"
Condition: index < itemList.Count
// The loop continues as long as the index is less than the number of items in the list
Sequence:
Assign: item = itemList(index)
// Perform actions with the current item
Log Message: "Processing item: " + item
Assign: index = index + 1
// Increment the index for the next iteration

In this example, the "Do While" loop continues to execute as long as the condition (index < itemList.Count) is true. The sequence of activities inside the loop processes each item in the "itemList" by logging a message and incrementing the index for the next iteration.

The "Do 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.