Try to delete one of multi-instance task but nrOfActiveInstance didn't change.

hi, I’m trying to delete a task of multi-instance task with process instance modificatoin.cancelActivityInstance(). But I found nrOfActiveInstance didn’t change.
Did I use the right function? Or should I modify nrOfActiveInstance by myself?

Thanks for your help.

Hi @young , thank you for your question and welcome to the community. Have you checked that you are targeting the inner activity itself and not the multi-instance body? There is a good section in the docs on this topic:

The engine will take care of updating the variables associated with the multi-instance body such as nrOfActiveInstance, so you should not have to touch those. Could you share more of your modification code and maybe a snippet of your model too? This will help the community answer your question more quickly.

1 Like

hi herrier, I have read the doc about the modification, but shows how to add an instance for multi-instance task…
Here is the details about my question:
I have draw a model just like the one in the doc, only a parallel user task in it.
1

And I start the process with 3 instance of that parallel user task.
Then I see that in act_ru_variables table, created 3 vars:

nrOfInstances=3
nrOfCompletedInstances=0
nrOfActiveInstances=3

After that, I try to use funcion below to delete one of 3 instance

        runtimeService.createProcessInstanceModification("ef38958e-d89e-11ef-b39f-5405db14393c")
                .cancelActivityInstance("Activity_1sqtibf:ef3e13ec-d89e-11ef-b39f-5405db14393c")
                .execute();

then vars in act_ru_variables change to:

nrOfInstances=3
nrOfCompletedInstances=0
nrOfActiveInstances=2

which is weird that nrOfInstances does not change.

By the way, the Camunda version is 7.19.

Really thanks for your help.

I believe there is nothing wrong with these values.
Yes, only nrOfActiveInstances should decrease, as one instance has been canceled.
nrOfInstances is set when the execution reaches the activity marked as multi-instance (indicating the number of iterations).
nrOfCompletedInstances should only increase if an instance is completed normally, but in this case, it was canceled.

1 Like

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