cancel
Showing results for 
Search instead for 
Did you mean: 

Exclusive Gateway on multiple items

yisa
Champ in-the-making
Champ in-the-making
Hi,

I'm new to building workflow and is trying to figure out how to model below process using loop. The workflow is operated on a batch of items, however, evaluation in between needs to be done on individual item. I don't know how to evaluate each item using a loop.

1. Start Event ->
2. Java Service (to retrieve a batch of items and save into a list process variable) ->
3. User Task (to enter Approved/Disapproved status for each item in the batch) ->
4. Exclusive Gateway (to evaluate the based on status for each item)
               –> if item is Disapproved, invoke Subprocess_Disapproved with this item
               –> if item is Approved, continue
5. User Task (to enter more data associated with each item in the (approved) batch ->
6. Java Service (to do some calculation based on the data entered for each item and store final result for each item)
7. Exclusive Gateway (to evaluate the final result for each item)
               –> if final result is failed for the item, invoke Subprocess_Failed with this item
               –> if final result is pass for the item, continue
similar steps to 5, 6 and 7 are repeated.

My question is how do I implement step 4 and 7, where I need to check for multiple items. I can only evaluate one ${item.status == "Approved"}. How can I design it so that I can loop through all items in the list.

4 REPLIES 4

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Use multi-instance
http://www.activiti.org/userguide/#bpmnMultiInstance

Regards
Martin

yisa
Champ in-the-making
Champ in-the-making
Thanks for the reply. I have used multi-instance, but that's not the problem. Let me clarify my problem.

My workflow contains mostly tasks that processes multiple items in a batch mode (step 2, 3, 5,6), but condition evaluation at exclusive gateway can only evaluate one item at a time (step 4 and 7). Since I can't use multi-instance on exclusive gateway alone, seems like I have to put each exclusive gateway into a separated process just to use multi instance, then merge result back to continue in batch mode, like the following:

1 –> 2(batch) –> 3(batch) –> 4(new_process_to_check_condition) –> 5(batch) –> 6(batch) –> 7(another new_process_to_check)

That means every time when I have a condition to check, I need to create a new process so that I can loop through the items. Doesn't seem like an efficient way to model. So am I missing something?

Does this make sense?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

You could evaluate the condition in the script/service tasks to evaluate result (loop through items ; condition evaluation & setting result to the process variable). That could be one way. Another possibility is to implement bean to evaluate condition (http://www.activiti.org/userguide/#springintegration).

Regards
Martin

yisa
Champ in-the-making
Champ in-the-making
Thanks for the quick reply! I'll try to use a service task then.