Fetching the next task information in the previous task using task api

Hi,

I have a scenario like after completing the user task there is a service task followed by another usertask.
I need to fetch only the user task information of the upcoming task from the previous task.
engine-rest/task api is returning null response when i try to invoke the same from previous user task or at the end of service task.

Can someone help on this issue.

Thanks and Regards,
Vinu S

Hi @vinu_s,

I don’t quite understand what you are trying to achieve. What Information in particular are you looking for?

KR
Martin

Hi @vinu_s,

If I understand you well,
In your case, user task is followed by service task where completing the user task and executing the service task is part of the same unit of work and because of that data provided in user task wouldn’t be committed until service task is finished and therefore data is not accessible from the service task.

To be able to commit data of user task before execution of service task then you can set camunda:asyncBefore of service task to true as below

<serviceTask id="service1" name="Service1" camunda:asyncBefore="true" camunda:class="my.custom.Delegate" />

This way you put a transaction boundary before the service task to allow data to be persisted before the execution of the service task.

https://docs.camunda.org/manual/7.10/user-guide/process-engine/transactions-in-processes/#transaction-boundaries

Thank you @hassang . For service task scenario it worked fine.

I have one more query, the above logic applies to call activities also.

Supposing i have a usertask followed by call activity then another usertask whether asyncBefore will help in fetching the next user task in the main process.

In the case of call activity, a new process instance of the called subprocess is created and in order to share data between the main calling process instance and the called sub process instance you should pass in/out variables

https://docs.camunda.org/manual/7.8/reference/bpmn20/subprocesses/call-activity/#passing-variables