cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a loop in flow

rvashishth
Champ in-the-making
Champ in-the-making
Hi

I need to implement a loop flow in my process, i couldnt find loop construct in bpmn, below is my requirement,


start event —> java service(fetch users) —–> send mail to fetched users ——> get approval from all ——> if all approved —–> end event


Thanks,
Rahul
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ

rvashishth
Champ in-the-making
Champ in-the-making
Thanks, I have achieved creating loop. sorry not to explore the docs properly.  Please help me for the next one as well.

Now I am looping a Java Service Task, by passing a process variable list, and in the execute method i am getting usernames from the list by creating a execution variable. Now i need to check the condition for n number of users, if all users say true than only i need to move to next construct.
How i can evaluate the boolean result of n loop to a single result ??

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

My understanding:
1. all users have to answer.  - (multiinstance loop is fine. )
2. If at least one of them says "No" - I do not know what should happen
3. If all of them says "Yes" - continue in the process execution.

for 2. and 3. use exclusive gateway with decision (store decision results in process variables and evaluate them in the transitions from exclusive gateway.)

Regards
Martin

rvashishth
Champ in-the-making
Champ in-the-making
Is it okay to store the result for each iteration in a single process variable, since ServiceTask instance is singleton and will be shared by other process as well. What if some other thread of execution modifies the value of ServiceTask class variable ?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,
Is it okay to store the result for each iteration in a single process variable,
it is ok in the case of sequential multiinstance loop. (In the case of parallel multiinstance loop you can get exception (concurrent modification) - you can use one variable instance per iteration).

What if some other thread of execution modifies the value of ServiceTask class variable ?

I propose to use process instance variables.

Regards
Martin