ForEach

ForEach component is a control flow component which enables you to process each item in an object, in an order of first to last.

This component can be used to iterate through Collections, Datatable Rows, Arrays, Lists and objects.

Screenshot

Ports

The ForEach component exposes Control In, Control Out, Data In and Data Out ports by default.

Port Description
Control In Must be connected to the Control Out port of one or more components.
Control Out Must be connected to the Control In port of any other component. For Each component exposes the following two types of Control Out ports.
Control Out Port: Control is passed to this port once all the objects in the collection have been iterated through. This port is connected to the Control In port of any other component if required.
Port to iterate in loop: Execution is passed to this port ForEach object in the collection. This port is connected to the Control In port of the component collecting the list.
Collection Must be connected to the Data Out port of another component from where data is to be collected.
Current Object Must be connected to the Data In port of another component from where data is to be collected.

Properties

To edit the properties of the ForEach component, in the lower-right pane, change the required property. You can edit the following properties:

Property Description
Search Search for the respective property.
Delay After Execution Specifies the wait time (in seconds) after the action is executed.
Delay Before Execution Specifies the wait time (in seconds) before the action is executed.
Delay ForEach Execution (Seconds) Specifies the wait time (in seconds) ForEach step of the execution until the ForLoop ends.

Example

Let us consider an example and retrieve names from a list.

Screenshot

To use the ForEach component:

  1. Add a Script component for entering the code with the list of values to be returned in an order.

  2. To add a Script component:

    • In the Toolbox, expand General.
    • Drag the Script component and drop it in the Design surface.
    • Double-click the component title bar.

      The Script Editor window is displayed.

      Screenshot

    • Enter the code to retrieve data in Script(VB.NET).

      Screenshot

    • Click Validate, to verify the code.

    • Click OK.

  3. Add the ForEach component to retrieve the list in the Script component in an order. To add a Script component:

  4. In the Toolbox, expand General.

  5. Drag the Script component and drop it in the Design surface.

  6. Add a MessageBox component to display output of the ForEach component.

  7. To add the MessageBox component:
    • In the Toolbox, expand General.
    • Expand the MessageBox component, drag Show component and drop it on the Design surface.
  8. Connect:
    • The control ports of all components.
    • The Data out port of the Script component to the Data In port of the ForEach component.
    • The Port to iterate in loop Control Out port of the ForEach component to the Control In port of the MessageBox component.
    • The Data out port of the ForEach component to the Data In port of the MessageBox component.
  9. In the toolbar, click Run.

    The first value of the list is displayed.

    Screenshot

  10. Click OK to display the next value in the list.

    Screenshot