Associating loop activity instances with different items

In multi-instance loops, you can associate each instance of an activity with a list item.

About this task

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:

  • As a prerequisite, you must already have defined a private variable that holds the list of items that you want to iterate through, for example, tw.local.ListofItems. This variable is used in the built-in tw.local.ListofItems.listLength JavaScript function, where .listLength calculates the length of the item list.
  • You associate each activity instance with a specific item in the list by using the tw.local.ListofItems[tw.system.step.counter] JavaScript, where [tw.system.step.counter] specifies which item to be retrieved from the list.

Procedure

  1. In the process 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 Loop, 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.
  7. Click Save or Finish Editing.