activities
latest
false
UiPath logo, featuring letters U and I in white
Workflow Activities
Last updated Nov 26, 2024

For Each

UiPath.Core.Activities.ForEach

Description

Performs an activity or a series of activities, specified in the Body section, on each element of a collection. The elements can be referenced in the activities in the Body section by using the iterator variable, item.

Project compatibility

Windows - Legacy | Windows | Cross-platform

Cross-platform configuration

  • In - A collection of items to iterate over. This field supports only IEnumerable values.
Body
  • Activities placed inside are executed if the condition is true.
Show additional properties
  • Item name - The name by which to refer to the current item in the iteration. Using a name that describes the item makes it easier to identify.
    Note:
    The value of the In field must be a collection of homogenous objects.
  • Argument type - A dropdown list that enables you to choose what variable type you want to use with the activity.
  • Condition - If the condition is true, the Body of the activity is executed.
  • Max Iterations - Maximum number of times the activity is executed.
  • Index - A zero-based index that specifies which element of the current collection is being iterated, stored in an Int32 variable.

Windows configuration

Designer panel
  • In - Specifies the list to iterate through.

Body

  • Activities placed inside are executed if the condition is true.
  • Common
    • DisplayName - The display name of the body of the activity.
  • Misc
    • Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
Properties panel
  • Item name - The name by which to refer to the current item in the iteration. Using a name that describes the item makes it easier to identify.
  • Argument type - A dropdown list that enables you to choose what variable type you want to use with the activity.
  • Condition - If the condition is true, the Body of the activity is executed.
  • Max Iterations - Maximum number of times the activity is executed.
  • Index - A zero-based index that specifies which element of the current collection is being iterated, stored in an Int32 variable.

Windows - Legacy configuration

Designer panel
  • ForEach - The name by which to refer to the current item in the iteration. Using a name that describes the item makes it easier to identify.
  • In - Specifies the list to be iterated through.

Body

  • Activities placed inside are executed if the condition is true.
Properties panel
Common
  • DisplayName - The display name of the activity.
Input
  • Condition - If the condition is true, the Body of the activity is executed.
  • MaxIterations - Maximum number of times the activity is executed.
Misc
  • Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
  • TypeArgument - A drop-down list that enables you to choose what variable type you want to use with the activity.
  • List of items - The variable whose values you want to iterate. This field supports only IEnumerable variables.
    Note:
    • When changing the argument type, the content of this activity is deleted.
    • The value of the List of items field must be a collection of homogenous objects.

Output

  • Index - A zero-based index that specifies which element of the current collection is being iterated, stored in an Int32 variable.

Example of using the For Each Activity

For this example, we use a simple IEnumerable variable comprised of three elements, displaying each of them in a Message Box:
  1. Create a new Process and drag a For Each activity into the workflow designer.
  2. From the Variables panel, create a new IEnumerable variable, called List with the following value:
    {"one", "two", "three"}{"one", "two", "three"}
  3. Insert the List variable in the Values property of the For Each activity.
  4. Drag a Message Box activity into the Body section of the For Each activity.
  5. Insert the item iterator variable into the Text property field of the Message Box activity.
  6. Run the file. The For Each activity iterates through each of the values specified in the List variable and displays it in a separate message box.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.