Strange behaviour of Process Instance Modification with Call activity

Hello!
I found a bug in ProcessInstanceModification Java API (v 7.4) and couldn’t resolve it, could anyone help me?

I have a main (parent) process and call activity in it.
Current task is “child_form”.

I create simple modification:

engine.getRuntimeService().createProcessInstanceModification(childInstanceId).
startBeforeActivity(“child_service_before”).
cancelActivityInstance(“child_form:xxx”).execute();

and have steps in log:
child_service_before
gateway out (“true” )
gateway in
child_service_after
child_end_event

and process stops! It doesnt continue to “parent_service_after” step.

But if I run engine.getTaskService().complete(“child_form”), then it works ok, process goes to “parent_service_after” and finishes on “parent_end_event”. Thats why I think error is exactly in ProcessInstanceModification API.

Sounds like this bug: https://app.camunda.com/jira/browse/CAM-6294

Note that the order of modification instructions is important. If you first start, then cancel, the expected semantics are that the called instance is cancelled. That is because first you spawn a second token at child_service_before which completes immediately, and then you cancel the first token at child_form. In your case, you can swap the instruction order to get the desired effect.

Cheers,
Thorben

Thank you very much!
It works like a charm!

I was confused by example in documentation
https://docs.camunda.org/manual/7.4/user-guide/process-engine/process-instance-modification/

My final version:

engine.getRuntimeService().createProcessInstanceModification(childInstanceId).
cancelActivityInstance(“child_form:xxx”).
startBeforeActivity(“child_service_before”).
execute();