Process Variables in the custom loop

Hi,
During the designing some business process flow I need to go through some graph tree structure. So the diagram smth like this. But I cant understand how to set the same variable so, that for every Category task, this variable was different. And I expected that the last parallel gateway will wait untill all of the Category tasks will be submited, but process go further each time when I reached the botom of the tree in some branch. Can you have som ideas how to solve this problems, thanks in adnvanced.

Hi Peter,

I’m not sure what causes your problem because of missing information about your process.

But, I see two things you have to be aware of:

  • a parallel gateway only waits until an execution has arrived for each of the incoming sequence flows
  • a terminal end event kills all executions of the process instance

Maybe you can use a multi-instance subprocess / task to iterate over the subcategories.

Does this help you?

Greetings,
Philipp

Hi thanks for your reply!
The problem is that I need to have like step by step approvement through the tree structure:
{"name":"category1","id":1, "children":[{"name":"category11", "id":2, "children":[....]}]}. So when parent category task is finished new category tasks added that are actually children of the processed category. Multiinstance subrocess is a good idea! Thanks! But is there way to add instances of multitask ? I have designed this diagram and trying to change the parent array of categories, and logging shows that variable is changed but in tasks do not added.

Hi Peter,

is it right that you want to do a depth-first search? Then you process can look like

What do you mean with the following sentence?

Greetings,
Philipp

Hi Yes, firstly I want to do depth-first serch! Than after some User Task inside “go to subcategories” subrocess fill be submitted I want to do-second depth search and add instances of “go to subcategories” subrocess

Yeah, I actually found how to reach my goals: in the service task inside the subrocess I have added this code
execution.getProcessEngineServices().getRuntimeService().createProcessInstanceModification(executor.getProcessInstanceId()) .startBeforeActivity("categoryEvaluation").setVariableLocal("category", category) .execute();

But there is a problem when categories list consists only of one element. it writes
The variable "nrOfCompletedInstances" could not be found in execution with id 4ddd6897-03f7-11e6-afce-00e04e0331d4: value is null Do you have any suggestions how to solve this?

Thanks in advance

Hi Peter,

this variable is created when the execution arrives the multi-instance subprocess / task. I think this issue is caused by the process instance modification. You may modify the wrong execution or move it to the wrong activity. I’m not sure since I don’t know your process.

However, you should not use the process instance modification for this. I’m sure that it is possible to model the expected behavior without process instance modification.

Can you please describe exactly how the process should walk through the category tree structure. And from user perspective, what user task you should be created and when.

Greetings,
Philipp

Hi Philipp,
Thanks for your reply!

The process looks like I have several evaluations options: [“Relative to Business”, “Not relative to Business”, “Relative to Something else”]. And I have some kind of standard tree structure of Categories. Process starts with the root id of category and User task appears to evaluate the root Category and choose among children Categories of root element those categories that should be evaluated too (here should be created multi instance task). Then the same schema repeats with children Categories, when they are evaluated and grandchildren categories are choosen I am trying to modify process instance to add more instances of subrocess with “category” variable of grandchildren.

Hi Peter,

let’s try to do this by an example. Assuming that an example category tree looks like:

Root |-- A |---- A1 |------ A1.1 |------ A1.2 |---- A2 |-- B |---- B1 |---- B2 |-- C

When the user completes the task of the root category and selects the subcategories: A, B and C, then 3 tasks are open for the categories A. B and C. Now, when the user completes task for category A and select the subcategories A1 and A2 then 4 tasks are open: A1, A2, B and C.

You can model this behavior with the following process:

The process is started for the root category. When the task is completed then the process fetch the subcategories call this process recursively for each subcategory (parallel multi-instance call activity) .

Does this fit your requirements? If not, please descript the expected behavior by the example.

Greetings,
Philipp

Yeah, this is what I am trying to implement! Thanks for your reply it is what I want, and sorry for my a bit cloudy explanations!