Re-open/Rollback task in process instance

Looking for some possible solutions for below mentioned use cases:

  1. To reopen last completed (system/user) task in flowable existing process instance
  2. To roll back the flowable existing process instance. For e.g From Task 5 to Task 2 along with the compensating process.

Any one has any idea about the same, please suggest !

flowable-admin app allows to move execution to the specified state.

Thanks for the reply Martin !

Could you please specify which API to use for this ? As in admin there is way to migrate process instance which creates new process instance as far as I know. But here we want to make changes in the running process instance only.

Hi SantoshiP,

Could you please specify which API to use for this ?

Have a look on the following test in flowable source:

org.flowable.engine.test.api.runtime.RuntimeServiceTest#testSetCurrentActivityForSubProcessExecution
...
        runtimeService.createChangeActivityStateBuilder()
                .moveExecutionToActivityId(task.getExecutionId(), "taskBefore")
                .changeState();

migrate process instance which creates new process instance

Migration migrates current process instance to the new definition. No new process instance is created. (May be only in some special cases like migration to call activity…)

Regards
Martin

2 Likes

Sure Thanks ! Will check and get back to you in case if any issues.

Thanks
Santoshi

Hi Martin,

The suggested ChangeActivityStateBuilder solution is working fine in case we are reopening any system task flow executes further and works fine, but in case of user task (parallel activity) it reopens only the asked 1 but doesn’t execute the flow and also holds the process at that point no further execution happening.

Please find below the tried scenarios, and please suggest.

Scenario 1:
Process execution starts - user task executed - at 1 of the user task - created reopen request for already completed system task - desired system task got reopen - flow executed further and process ends.

Scenario 2:
Process execution starts - user task executed - at 1 of the user task - created reopen request for already completed user task - desired user task got reopen - no flow executed further and process holds.

Not sure why user task (parallel gateway task) reopening creates this issue. Any help would be appreciated !

Thanks,
Santoshi

May I ask you to prepare a simple jUnit test please?

mvn archetype:generate \
-DarchetypeGroupId=org.flowable \
-DarchetypeArtifactId=flowable-archetype-unittest \
-DarchetypeVersion=<current version> \
-DgroupId=org.myGroup \
-DartifactId=myArtifact

Hi Martin, i couldn’t understand the solution
can you explain me please?
@martin.grofcik

I was not able to understand the problem from your description - that’s why I asked you to prepare some jUnit test.

Hi Martin i found the solution from rest api thank the reply
@martin.grofcik

Can you help , which rest api u used to do this

can we use a boundary signal event to achieve this ?

Depends on the business requirements.

Thanks for the response @martin.grofcik .

Will the process activity state changes properly if I use the boundary signal or should I use the moveExecutionToActivityId() method ?

If I should use moveExecutionToActivityId() only, how can I get the source abd target activities ? In below sample you shared, how can I get the task ? I have only the process instance Id, with that can i get the current activity and its previous activity ?

moveExecutionToActivityId(task.getExecutionId(), “taskBefore”)

moveExecutionToActivityId() is not necessary.

Martin

thanks @martin.grofcik