# STRANGE BEHAVIOR? - Process Instance Modification

**URL:** <https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752>\
**Category:** Discussion & Questions\
**Created:** [January 6, 2024, 2:28am UTC](https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752 "2024-01-06T02:28:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![WilliamR.Alves](https://forum.camunda.io/user_avatar/forum.camunda.io/williamr.alves/32/27412_2.png) [@WilliamR.Alves](https://forum.camunda.io/u/WilliamR.Alves)\
**Post date:** [January 6, 2024, 2:28am UTC](https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752/1 "2024-01-06T02:28:08Z")

</div>

Hello guys!!!

[Camunda Platform 7.16 - Embedded Spring]

I had a behavior that seemed strange to me when using process instance modification through http calls through postman…

The scenario is as follows:

We had a problem that caused an incident in task 1 (Buscar cadastro Asaas), so I deployed a new processDefinition so that the new instances created by our application started correctly, and in this flow that had a problem in this task, I tried to do the modification of the instance, migrating it to service task 2 (Cadastrar cliente Asaas) see IMAGE 1.

[IMAGE 1]

 ![image](https://forum.camunda.io/uploads/default/original/3X/1/2/12b5f749de228e6b1e927365e2d8a1ffe9dd4d12.png)

I made the POST call to the Modification API passing the attributes as in IMAGE 2, (I wanted to migrate from task 1 to task 2)… however when executing this call, the instance simply disappeared from all the processes it was in. Below image of the HTTP POST call to the API.

[IMAGE 2]

 ![image](https://forum.camunda.io/uploads/default/original/3X/7/2/7244dd6b67de2ed3bc39bbfed5341434537ab8c5.png)

When I looked at the instance in question in the History API to check what happened, I noticed that the “state” is marked as “EXTERNALLY\_TERMINATED”, as in the image below:

[IMAGE 3]

 ![image](https://forum.camunda.io/uploads/default/original/3X/f/3/f3eb18cbef746837b4d506448479649a47d3a14f.png)

To explain better, this flow is initiated by a call activity that is inside a multi-instance, as shown in the image below:

 ![image](https://forum.camunda.io/uploads/default/original/3X/d/0/d091886e8e8ba26063815f2c1419a57255ad2988.png)

Has anyone had this same behavior? Can anyone tell me why this happens?

Thank you in advance for any response so we can reach a conclusion 😃

**William Robert Alves**

---

<div class="post-metadata">

**Author:** ![thorben](https://forum.camunda.io/user_avatar/forum.camunda.io/thorben/32/78_2.png) [@thorben](https://forum.camunda.io/u/thorben)\
**Post date:** [January 8, 2024, 2:16pm UTC](https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752/2 "2024-01-08T14:16:25Z")

</div>

Hi William,

> [@WilliamR.Alves](#):
>
> When I looked at the instance in question in the History API to check what happened, I noticed that the “state” is marked as “EXTERNALLY\_TERMINATED”

Could it be that there is no wait state anymore between task II and the end event? That would explain the behavior as follows: the modification instructions are executed in the order you submit them. So if you start the new token first, it will run until the end event and be consumed. Then you cancel task I. So the overall process instance gets cancelled, which is what `EXTERNALLY_TERMINATED` expresses.

Cheers,  
Thorben

---

<div class="post-metadata">

**Author:** ![WilliamR.Alves](https://forum.camunda.io/user_avatar/forum.camunda.io/williamr.alves/32/27412_2.png) [@WilliamR.Alves](https://forum.camunda.io/u/WilliamR.Alves)\
**Post date:** [January 8, 2024, 2:55pm UTC](https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752/3 "2024-01-08T14:55:57Z")

</div>

Hello @thorben!  
Thank you very much for your reply!

Our process is entirely automated, so I don’t have waiting states on Camunda until the end of the process, but I have some Async Befeore points to persist the data in Camunda’s DB… however from this stage onwards i used instance modification, we still have several other services tasks to be executed and they have not been called, including calls to external services.

In conversation with my brother @Jean_Robert_Alves he said that he has already experienced the same problem, and what he is doing to avoid it is making the request in 2 steps, one that just creates the new instance token as desired, and then makes a request separately to cancel the unwanted “token”.

**William Robert Alves**

---

<div class="post-metadata">

**Author:** ![WilliamR.Alves](https://forum.camunda.io/user_avatar/forum.camunda.io/williamr.alves/32/27412_2.png) [@WilliamR.Alves](https://forum.camunda.io/u/WilliamR.Alves)\
**Post date:** [January 10, 2024, 4:02am UTC](https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752/5 "2024-01-10T04:02:54Z")

</div>

Hey guys!

After some testing for this specific scenario, i found that the following request can be made using `transitionInstanceId`.

Below is what i did to solve it, so that future users who have the same question can find the answer they’re looking for:

In this case, the `activityInstanceId` field must be replaced by `transitionInstanceId` passing the `executionId` of this transition instance that you want to delete.

The call via postman / insomnia was as follows:

 ![image](https://forum.camunda.io/uploads/default/original/3X/2/7/27217e78564fdee147efdd777e9a14e99059a321.png)

As you can see, i started 2 instances using a specific id, as these are 2 activities after a parallel gateway, and finally in the same request i performed the “cancel” using the `executionId` of the instance that was used to create the other 2 new ones instances.

Programmatically this can be done with the following steps:

- We execute instance modification to create the new instance in the desired task.

- We look for the executionId of the transition instance (instance you want to delete) through the `GET process-instance/{processInstanceId}/activity-instances` API.

- Finally, we execute “cancel” by passing the value obtained as executionId from the step above, in the `transitionInstanceId` field.

This process can be carried out even if the modified instance is experiencing an incident.

That’s all folks! 🚀 🙏 👊

**William Robert Alves**

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [January 17, 2024, 4:03am UTC](https://forum.camunda.io/t/strange-behavior-process-instance-modification/49752/6 "2024-01-17T04:03:26Z")

</div>

Closed on January 17, 2024, 4:03am UTC

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