How can we modify the sequence of execution in multi-instance subprocess?

How can we modify the sequence of execution in multi-instance subprocess?

Initially I have declared 4 task in the list to be executed.
List list = Arrays.asList(“task-1”, “task-2”, “task-3”, “task-4”, “task-5”);

Now , once process started running and entered into set start time service task under subprocess I want to modify the above list i.e; I want to remove task-4 from the list and subprocess should run only 4 times not 5 times.

Hi @Manish_Tiwari - do you always want to remove task-4, or only under certain conditions?

@nathan.loding Not always. Basically I want to implement adhoc task on running instance. Is it possible?

Here I will remove task-4 under certain condition. or I can even add. I want to change the sequence.
Please help how can I do that?

Hi @Manish_Tiwari , The same can be achieved using completion_condition available inside multi-Instance component.

APPROACH-1

  • First, set a process variable (e.g. rerouted = true) based on the condition where you want to modify the sequence.

  • Then utilize that variable (rerouted) as completion_condition available inside multi-Instance component.

  • Add a ExOR gateway after your subprocess and check condition whether sequential flow has been rerouted or executed normally as per the original sequence.

  • If flow is rerouted, just send it back to the initial service-task and assign a rerouted sequence to the multi-instance sub-process.

Your flow will continue as per the modified sequence.


APPROACH-2
You can modify sequence stored as a process variable. Just modify the array stored inside camunda variable using different mechanism available to set variable programmatically.

1 Like

Hi @Manish_Tiwari - @Vikas_Sharma made the same suggestion I was going to make. You do not want to be programmatically altering your processes; instead, you want to model for these conditions.

2 Likes

@Vikas_Sharma Thanks your suggestion… it resolved my issue…

Thanks @nathan.loding and @Vikas_Sharma

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.