# How can I get case definition for a task?

**URL:** <https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449>\
**Category:** Uncategorized\
**Created:** [July 27, 2020, 1:05pm UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449 "2020-07-27T13:05:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkaiIto](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akaiito/32/1859_2.png) [@AkaiIto](https://forum.flowable.org/u/AkaiIto)\
**Post date:** [July 27, 2020, 1:05pm UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449/1 "2020-07-27T13:05:26Z")

</div>

I have a task that could either belong to a process or a case. I am able to get processInstanceId for a task. How can I get caseInstanceId for a given task?

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [July 28, 2020, 7:13am UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449/2 "2020-07-28T07:13:28Z")

</div>

Hi Akailto.  
org.flowable.task.api.TaskInfo

```
/**
 * Reference to a scope identifier or null if none is set (e.g. for bpmn process task it is null)
 */
String getScopeId();

/**
 * Reference to a sub scope identifier or null if none is set (e.g. for bpmn process task it is null)
 */
String getSubScopeId();

/**
 * Reference to a scope type or null if none is set (e.g. for bpmn process task it is null)
 */
String getScopeType();

```

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![AkaiIto](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akaiito/32/1859_2.png) [@AkaiIto](https://forum.flowable.org/u/AkaiIto)\
**Post date:** [July 29, 2020, 7:00am UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449/4 "2020-07-29T07:00:02Z")

</div>

Hi Martin,

If I use task query as TaskQuery::includeProcessVariables then getScopeId() method returns null.

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [July 29, 2020, 7:08am UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449/5 "2020-07-29T07:08:12Z")

</div>

Hi,

could you reproduce the issue in the jUnit test?  
It seems like a bug which can be easily fixed. (You can even provide a fix)

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![AkaiIto](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/akaiito/32/1859_2.png) [@AkaiIto](https://forum.flowable.org/u/AkaiIto)\
**Post date:** [July 29, 2020, 7:21am UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449/6 "2020-07-29T07:21:49Z")

</div>

Hi Martin,

I am using  
`TaskQuery query = processEngine.getTaskService().createTaskQuery().includeProcessVariables();`

This query does not load the ScopeId.

Regards

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [July 30, 2020, 5:15pm UTC](https://forum.flowable.org/t/how-can-i-get-case-definition-for-a-task/6449/7 "2020-07-30T17:15:25Z")

</div>

> [@AkaiIto](#):
>
> includeProcessVariables

That’s because you’re requesting process variables. There’s no such thing for cases, you’d need to do two queries (2nd one using the case instance id).
