creating process instance modification while starting the process instance

Hi,
I use the Java API.
I’m trying to implement the following scenario:
create a new process instance that will start the execution from a certain activity.
when I try to do the following:
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(key, workflowExecutorId, globalInputs);
runtimeService.createProcessInstanceModification(processInstance.getId())
.startBeforeActivity(camunaActivityId)
.execute();

I receive two executions - one regular and one that starts from the camundaActivityId mentioned , I want to receive only onw execution that starts from the camundaActivityId, what is the right way to do so?
Thanks!

Hello my friend!

Maybe I didn’t understand his idea very well, but…

When you do a “processInstanceModification”, Camunda creates a kind of “clone” of that running instance, and initializes this copy in the activity you suggested with startBeforeActivity.

However, with this, the instance in which you “cloned” was not finalized… so theoretically you have 2 instances with the same data.

To do this, you will also have to add the “cancel” command to terminate the previous instance, which you “cloned”, canceling the instance that has the “transitionInstanceId”, which indicates that the instance in question was “cloned”.

I hope this helps.

William Robert Alves

thanks for your answer! what do you mean by cancel command? the cancelActivityInstance on the modifications or something else?

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