Configuring an activity for multi-instance loops
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.
Before you begin
Restriction: Ad hoc start events are not supported
in multi-instance loop activities. If you are using looping, do not
define ad hoc actions for Process Portal users to start.
Procedure
Associating loop activity instances with different items
About this task
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
- In the BPD diagram, select the activity that you want to configure.
- In the properties, select General.
- Under Behavior, select Multi-instance Loop from the Loop Type list.
- Under Multi-instance Loop, enter tw.local.ListofItems.listLength in the Start Quantity box.
- On Data Mapping, under Input Mapping, select, or type the following input string: tw.local.ListofItems[tw.system.step.counter]
- For the Ordering and Flow Condition settings, refer to steps 5 and 6 in the procedure described earlier.
- Save your changes.