cancel
Showing results for 
Search instead for 
Did you mean: 

How to define parallel tasks dynamically?

vamsinipun
Star Contributor
Star Contributor

Hi Team,

I am using activiti in my spring web application. I was defined one process as follows,

Here i was defined parallel tasks are three. But in my scenario, it may be one or more parallel tasks then please let me know how can i define the diagram? Please help me out this?

Thanks

13 REPLIES 13

vamsinipun
Star Contributor
Star Contributor

Please anyone reply me about this

hari
Star Contributor
Star Contributor

Go for a multi instance user task, based on a list of objects. The execution depends on the number of objects that are there in the list. 

vamsinipun
Star Contributor
Star Contributor

Hi Hari,

Thank you for your reply. Please how can i get list objects in multi instance tab.

Here i was placed count ( 2 ) statically at loop cardinality. how can i dynamic this from db.

Thanks

hari
Star Contributor
Star Contributor

Instead of setting the loop cardinality do it something like this. 

Collection is the list on which you want to iterate upon. and Element variable is what you call an item in the list. 

Ensure the List is available by the time it reaches this(User Task, Call Activiti, etc) step for it to iterate as per your need. 

vamsinipun
Star Contributor
Star Contributor

Ya i tried like that. I was prepared the list one of the task listener. But It is skipping the list when users are available. please help me out of this.

and list as like List<String> format. Now how can i set this.

hari
Star Contributor
Star Contributor

Try doing it in a service task instead of a task listener Or start the process with the variable containing the list of values. 

vamsinipun
Star Contributor
Star Contributor

Thank you Hari. Your suggestion is helped me. But small issue, Now the instances are two. the tasks are visible to both users until they complete to it. Please let me know, if user1 completed his task then the task is not visible to that user. this scenario missing. i need to achieve this. if user1 completed his task it is visible to both users until another user also complete the task.

please tell me how to come out from this.

Thanks

hari
Star Contributor
Star Contributor

Didn't get you here. 

If you need the task to be visible to all users but only one user should complete it, then you can assign the task to a group. All users who are part of the group will be able to see that task. One of the users who wish to work on it will claim it. Once the task is claimed, then it will no longer be in the group and hence others will not be able to see it.  The user who claimed it can complete the task once he did what he has to do.