A User-Defined loop enables you to control the iteration cycle by defining a rule to determine when to exit the loop. The appearance of the designed loop can be the same as a For Each loop. At runtime, processing continues until your exit condition is true.
To create a User-Defined loop:
Create a loop in the business process.
Open the Loop complex activity and add the activities to be performed in the loop.
Construct the logic to test for the exit condition for termination of the loop. The logic path that continues the loop should connect to the OUT node of the loop. The logic path that terminates the loop should connect to a break, compensate, fault, or end.
Note: An example of the logic to test for the exit condition can be in the form of a single rule. The true path for the rule is connected to the OUT node. The false path exits the loop with a break, compensate, fault, or end. If an end is used it ends the entire process, not just the loop. If a fault or compensate is used, a fault or compensate handler must also be added to the loop to provide an output terminal for this branch of logic continuing on from the loop activity. Using a break causes the loop to terminate and process control flow to continue in the branch connected to the output terminal of the loop.
Close the loop and specify its properties based on the following information:
Property |
Description |
Loop Type |
Selection of type of loop |
Counter Context Reference |
Optional identification of the context variable that is incremented after each iteration in the loop |
Counter Increment |
The literal or context reference that specifies the integer value that is added to the counter after each iteration. |
Counter Initial Value |
The literal or context reference that specifies the integer use as the starting value for the counter. |
Assign the Loop Type property as User Defined.
To keep count of the number of instances processed in the iteration for later use in the business process, specify the Counter Context Reference you are using to store the number of iterations processed in the loop.
Click in the value
column for the Counter Context Reference property. Click and select the context variable.
Note: This requires that you created a context variable with an integer data type to retain the number of iterations. See Adding Context Variables.
Identify the Counter Increment
If a Counter Context Reference is being used, it is incremented by this amount at the completion of each loop iteration.
Click in the value
column for the Counter Context Reference property. Click and select the context variable.
Note: This requires that you created a context variable with an integer data type to retain the number of iterations. See Adding Context Variables.
Identify the Counter Initial Value property.
By default, this value begins the count of the iteration processing at zero.
To change the number of the first iteration in the loop, select Integer when the Data Type Selection dialog box appears and enter the starting number for the counter.