IBM BPM, V8.0.1, All platforms > Create processes in IBM Process Designer > Modeling processes > Create a business process definition (BPD) > Implementing activities > Create loops

Configure an activity for multi-instance looping

Using multi-instance loops, you can dynamically run multiple unique instances of the same activity sequentially or in parallel. When you run an activity that is configured for multi-instance loops, a unique token is created for each instance of the activity.


Procedure

  1. In the BPD diagram, select the activity that you want to configure.

  2. In the properties, select General.
  3. Under Behavior, select Multi Instance Loop from the Loop Type list.
  4. Under Multi Instance Looping, type a value in the Start Quantity box. This value sets the number of instances that are created at run time. To specify a variable that can be used for this setting, click the variable icon to select it or type the variable name into the Start Quantity box.

    Tip: For information about how to associate each loop activity instance with a specific item in a list, see Associating loop activity instances with different items.

  5. From the Ordering list, select one of the following options:
    Option Description
    Run Sequential Resulting instances are run sequentially until the last instance of the activity is complete.
    Run in Parallel Resulting instances are run at the same time until all instances are finished or until the condition that you specify is met.

  6. For parallel ordering, select one of the following options from the Flow Condition list:
    Option Description
    Wait for all to finish (All) Looping continues until all resulting instances of the activity are finished.
    Conditional Wait (Complex) Looping continues until the condition that you specify in the following step is met.

  7. For complex flow conditions, type the JavaScript to implement that condition in the Complex Flow Condition box.

  8. If you want active instances of the activity to be canceled when the preceding condition is met, select Cancel Remaining Instances.
  9. Save your changes.

Create loops


Associating loop activity instances with different items

You can configure activity instances in multi-instance loops so that each instance corresponds to one specific item in a list.

For example, if you have five instances of an activity and five orders in a list, you might want to associate each instance with an order in the list.

To set up the activity instance-item association, the following key settings are required:


Procedure

  1. In the BPD diagram, select the activity that you want to configure.

  2. In the properties, select General.
  3. Under Behavior, select Multi Instance Loop from the Loop Type list.
  4. Under Multi Instance Looping, enter tw.local.ListofItems.listLength in the Start Quantity box.

  5. On Data Mapping, under Input Mapping, select or type the following input string: tw.local.ListofItems[tw.system.step.counter]

  6. For the Ordering and Flow Condition settings, refer to steps 5 and 6 in the procedure described earlier in this topic.
  7. Save your changes.