# Sub Process User Task Execution Issue

**URL:** <https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958>\
**Category:** Discussion & Questions\
**Tags:** getting-started\
**Created:** [January 10, 2023, 5:49am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958 "2023-01-10T05:49:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naveen\_KS](https://forum.camunda.io/user_avatar/forum.camunda.io/naveen_ks/32/22369_2.png) [@Naveen\_KS](https://forum.camunda.io/u/Naveen_KS)\
**Post date:** [January 10, 2023, 5:49am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/1 "2023-01-10T05:49:46Z")

</div>

Hi,

If there are any subprocess, how can we make the task as complete, since it’ll create new process instance key for sub process, how can we get the task details?

For my usecase, I’ll be calling an API call which has process instance id, using process instance ID, I’m taking Active task details using Operate API, and using that I’ll get the task ID and get the task details from task list.

Process instance ID is sent when process instance is created for the workflow.

But in case of sub process, we cant use parent process instance ID to perfrom operation.

In case of Camunda 7 business key can be used, which will be same for parent and sub process.

---

<div class="post-metadata">

**Author:** ![StephanHaarmann](https://forum.camunda.io/user_avatar/forum.camunda.io/stephanhaarmann/32/21924_2.png) [@StephanHaarmann](https://forum.camunda.io/u/StephanHaarmann)\
**Post date:** [January 10, 2023, 6:42am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/2 "2023-01-10T06:42:18Z")

</div>

Hi,  
The subprocess should have a propertie called `parentkey` containing the process instance ID of the parent process (Operate API):

> **[Overview | Camunda 8 Docs](https://docs.camunda.io/docs/apis-tools/operate-api/overview/)**
>
> Operate API is a REST API and provides searching, getting, and changing Operate data. Requests and responses are in JSON.

> [@Camunda 8 Get Parent Process Instance Key](https://forum.camunda.io/t/camunda-8-get-parent-process-instance-key/40765):
>
> Hi, which is the path (zeebe client, operate api, …) to get the Parent Process Instance Key of a called activity?

---

<div class="post-metadata">

**Author:** ![Naveen\_KS](https://forum.camunda.io/user_avatar/forum.camunda.io/naveen_ks/32/22369_2.png) [@Naveen\_KS](https://forum.camunda.io/u/Naveen_KS)\
**Post date:** [January 10, 2023, 10:04am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/3 "2023-01-10T10:04:02Z")

</div>

HI @StephanHaarmann , My use case if bit different here.  
I have one API which takes the businesskey for user task to completed, using business key I’ll take the current active task and I’ll mark the task as complete.(In case of sub process also business key will be same, so it’ll work).

In C8, since there is no business key, I need to rely on process instance key, so when workflow process instance gets started, I’ll return the process instance ket so for all the user tasks one API is used which gets the Process instance key to get the active tasks and completed tasks and mark the task complete.

If sub process has a user task and I can use parent process instance key to perform operation. When Sub process is created by camunda, even though it’ll have parent process details, my application is not aware of this, and all the API calls will happen based on parent process instance key.

---

<div class="post-metadata">

**Author:** ![StephanHaarmann](https://forum.camunda.io/user_avatar/forum.camunda.io/stephanhaarmann/32/21924_2.png) [@StephanHaarmann](https://forum.camunda.io/u/StephanHaarmann)\
**Post date:** [January 10, 2023, 2:11pm UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/4 "2023-01-10T14:11:15Z")

</div>

I believe that this requires multiple API request currently:

1. You could search for a business key variable. You will receive all instances of this variable across all process instances
2. Given the process IDs you can search for open tasks
3. You can complete the task via the tasklist API.

---

<div class="post-metadata">

**Author:** ![Naveen\_KS](https://forum.camunda.io/user_avatar/forum.camunda.io/naveen_ks/32/22369_2.png) [@Naveen\_KS](https://forum.camunda.io/u/Naveen_KS)\
**Post date:** [January 11, 2023, 3:56am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/5 "2023-01-11T03:56:50Z")

</div>

Hi @StephanHaarmann, Currently I’m not storing businessKey variable.  
Could you please help in how I can fetch the variables, from zeebeClient I dont see an option to fetch the variables.

---

<div class="post-metadata">

**Author:** ![StephanHaarmann](https://forum.camunda.io/user_avatar/forum.camunda.io/stephanhaarmann/32/21924_2.png) [@StephanHaarmann](https://forum.camunda.io/u/StephanHaarmann)\
**Post date:** [January 11, 2023, 6:14am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/6 "2023-01-11T06:14:41Z")

</div>

Hi @Naveen_KS,

This functionality is not offered by Zeebe. Therefore, it is not included in the Zeebe client.

1. You can use Operate API to search for variables (i.e., with a certain name and value). This will also give you the process instance Key.  
[Operate API (REST) | Camunda Platform 8 Docs](https://docs.camunda.io/docs/apis-clients/operate-api/#variable)
2. Afterward, you can use the Tasklist API to query for tasks of the respective process instances.  
[tasks | Camunda Platform 8 Docs](https://docs.camunda.io/docs/apis-clients/tasklist-api/queries/tasks/)  
[Task | Camunda Platform 8 Docs](https://docs.camunda.io/docs/apis-clients/tasklist-api/objects/task/)

---

<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 31, 2024, 10:37am UTC](https://forum.camunda.io/t/sub-process-user-task-execution-issue/41958/7 "2024-01-31T10:37:12Z")

</div>

Closed on January 31, 2024, 10:37am UTC


