Modifying process instance is terminating process instance

Hi All,
Since I am new to Camunda, facing issue in Process Modification

Problem Statement :
I am trying to modify the processInstance using process modification API using runtime service but when I am trying to move execution to particular transition flow (flow-x) using startTransition method the flow is getting executed but the instance getting closed after reaching at the End_Event_subprocess_B

Expectation - I want behavior where the flow should complete execution till ‘End_Event_subprocess_A’ and then move to gateway (Gateway-3) placed after Subprocess-A.

Code -
modificationBuilder.startTransition(flow-x)
.setVariables(variable)
setAnnotation(some-text)
.cancelAllForActivity(activity-2) //instance Currently at activity-2
.execute();

Please find the BPMN diagram below.

And I am using 7.18.4 EE version.
Appreciate any suggestion or solution to get expected behavior.

Hello my friend!!!

I’ve never done a process with so much “extended sub-process”… but maybe your problem could be in the gateway between one sub-process and another.

I suggest placing a “user task” to make the process stop after the exit of subprocess B… and one after the gateway, to test and verify if the error really is in the subprocess or in the gateway.

Despite not knowing the context of the business in which it operates… my question is:

  1. Is it really necessary so many subprocesses?
  2. Couldn’t it be done all in one or maybe 2?

I hope this helps.

Regards.
William Robert Alves

Hi @Swaraj1,

the docs explain the concept of ancestor activities here: Process Instance Modification | docs.camunda.org

Maybe you can provide your subprocesses as ancestors during the modification?

Hope this helps, Ingo

Hi @WilliamR.Alves ,

Thank you for the suggestion.
To answer your question -

  1. Yes
  2. No, It can’t be due to requirements.

Thanks!

Hi @Ingo_Richtsmeier ,

I have gone through it and tried leveraging this but in my context it’s not working as it’s executing all the listeners again and I don’t want that.

Really Appreciate for the input!

Thanks!

Hi @Swaraj1,

You can skip the listener execution if you don’t need them or they will cause issues: Process Instance Modification | docs.camunda.org

Hope this helps, Ingo