How to create dynamic tasks in a process?

cancel
Showing results for 
Search instead for 
Did you mean: 
ltrichaud
Active Member

How to create dynamic tasks in a process?

Hello,

In a process, I would like to create tasks dynamically based on parameters passed at the creation of the process.
For example, from ADF, I would like to create a form that allows me to select from 1 to N reviewers.
On APS, I would like the process to be able to create N proofreader tasks.
Is it possible to loop through a list of proofreaders to create one task per proofreader?
I specify that the tasks should not be in parallel. If Proofreader 1 rejects the document, the process must stop.

Thank you

2020-09-07 16_12_37-_Process Services Editor.png

4 Replies
abbask01
Senior Member

Re: How to create dynamic tasks in a process?

Instead of creating the task "dynamically" (ssuming throught java code). you can try an inbuilt feature called multi instance. you can provide your list of proofreaders (user ids) as parameters and assign each task using a variable. 

As for you rejection condition, you can store outcome of each task in a variable and check that variable's value in completion condition.

more on this in docs - https://docs.alfresco.com/process-services1.11/topics/user_task.html

a working example is posted here - https://hub.alfresco.com/t5/alfresco-process-services/parallel-multi-instance-dynamic-task-candidate...

hope it helps.

Regards,
Abbas
ltrichaud
Active Member

Re: How to create dynamic tasks in a process?

Hello,

Thank you for your answer !
indeed the 'multi instance' feature would suit me perfectly. Except that I'm a bit blocked! What should we put in the "collection" field ? a list ? a variable ? In APS, you can only create string, int, boolean variables, but no array...

Would an array of the style ['usernameA", "usernameB", "usernameC"] be enough in this field ?

If yes, can we assign each task to each user via his username?

Thanks in advance for your help Smiley Happy

abbask01
Senior Member

Re: How to create dynamic tasks in a process?

Collection requires a serializable list, e.g. you can do it via a groovy script (or java code).

 

List<String> groups = [ '1001', '1002', '1002'] as String[];
execution.setVariable('myCollection', groups );

 

 

You'll have to provide db userId for task assignment.

Regards,
Abbas
ltrichaud
Active Member

Re: How to create dynamic tasks in a process?

Thank you for your help! Your code works!
Except that, I choose the "sequential" multi instance type, it doesn't work properly. This mode launches the tasks all at the same time... I think it's a bug. 

The behavior is the same if we select the type of multi-instance "parallel".