Skip to main content

Using ForEach Activity

For Each is used to iterate through the collection of items such as an array, data tables, lists, or the elements for a specified number of times. It will loop through the collection, and each time through the loop, it will use the next item from the collection. It starts with the first item in the array (the one at index 0) and continues through to the last item in the array.

Let us understand For Each activity with an example process. Here is an example that takes a list of numbers and displays the count, sum of even, and odd numbers as output.

Come, let's create this process in Process Designer:

Step#1

Launch and create a new process in Process Designer

  • Launch Process Designer from the Windows Start menu located under IntelliBuddies Enterprise

Step#2

Create New Process

  • Click on New Process and fill in the new process details

Step#3

  • Add array variable to hold the list of numbers.
  • Int32 variables to hold count and sum for even and odd numbers.

Step#4

  • Add For Each by setting type as Int32.
  • Iterate through the integer array to get number.

Step#5

  • Add If Else by setting the condition to check whether numbers are even.
  • In order to check for even number, compute remainder by divinding each number by 2 and see it is 0.
  • Assign computed values using Multi Assign activity.

Step#6

Step#7

Save the process

  • From the Design tab ribbon, click on Save

Step#8

Run the process

  • From the Design tab ribbon, click on Run

Step#9

Ensure the process executes and displays the count and sum of even and odd numbers in the given array.

Download Example (C#)