# CMMN query for multiple business keys or names

**URL:** https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502
**Category:** Flowable Engine
**Created:** [July 5, 2022, 9:15am UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502 "2022-07-05T09:15:23Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ErmannoRusso](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/ermannorusso/32/2855_2.png) [@ErmannoRusso](https://forum.flowable.org/u/ErmannoRusso)
#### Post date: [July 5, 2022, 9:15am UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/1 "2022-07-05T09:15:23Z")

</div>

Hello, is there any way with the Java API to query caseInstances for a list of multiple business keys and/or names? I see this can be done for case instance variable values, but I didn’t find a way to do it for business keys… the following code snippet doesn’t work, it only returns the last case instance of the list.

```auto
 var query = runtimeService.createCaseInstanceQuery().includeCaseVariables().or();
 documentIds.forEach(documentId -> query.caseInstanceBusinessKey(documentId));
 query.endOr();

```

I’m using version 6.7.2 with Spring Boot.

---

<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 5, 2022, 1:05pm UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/2 "2022-07-05T13:05:15Z")

</div>

Wouldn’t

```auto
cmmnRuntimeService.createCaseInstanceQuery()
    .or()
        caseInstanceBusinessKey(somevalue)
    .endOr();

```

work?

---

<div class="post-metadata">

### Author: ![ErmannoRusso](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/ermannorusso/32/2855_2.png) [@ErmannoRusso](https://forum.flowable.org/u/ErmannoRusso)
#### Post date: [July 5, 2022, 2:06pm UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/3 "2022-07-05T14:06:40Z")

</div>

Thanks for your reply. I just tried and it doesn’t work, it’s the same as the snippet I posted, it only takes into account the last value you give, it doesn’t seem to support multiple values.

---

<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 5, 2022, 2:29pm UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/4 "2022-07-05T14:29:58Z")

</div>

Hmm, you’re right. The or() api’s only stores the latest value (that’s the case for all fields over all queries). The proper solution would be to add businessKeyIn(), which would be a nice contribution ;-).

---

<div class="post-metadata">

### Author: ![ErmannoRusso](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/ermannorusso/32/2855_2.png) [@ErmannoRusso](https://forum.flowable.org/u/ErmannoRusso)
#### Post date: [July 5, 2022, 2:51pm UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/5 "2022-07-05T14:51:35Z")

</div>

Actually, for variable values it works, because AbstractVariableQueryImpl contains an ArrayList of variable values, which can be also different values of the same variable. But there is nothing like that for the business key and the name of the case instance.

---

<div class="post-metadata">

### Author: ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)
#### Post date: [August 17, 2022, 11:43am UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/6 "2022-08-17T11:43:38Z")

</div>

@ErmannoRusso there is indeed a functionality missing for query for multiple business keys and names for a case instance. Would you like to provide a PR that will add this functionality?

Cheers,  
Filip

---

<div class="post-metadata">

### Author: ![ErmannoRusso](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/ermannorusso/32/2855_2.png) [@ErmannoRusso](https://forum.flowable.org/u/ErmannoRusso)
#### Post date: [August 19, 2022, 9:31am UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/7 "2022-08-19T09:31:38Z")

</div>

Hi Filip, I don’t think I can yet, I’m quite new with the product and still getting familiar with it.  
Maybe in the future if nobody else does it before me!

---

<div class="post-metadata">

### Author: ![antonio.pascual](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@antonio.pascual](https://forum.flowable.org/u/antonio.pascual)
#### Post date: [April 21, 2025, 3:54pm UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/8 "2025-04-21T15:54:43Z")

</div>

Hi @filiphr,

I’m also interested into this. Is still not possible to query for multiple business keys? I would also like to query for multiple businessStatuses.

Thanks.

---

<div class="post-metadata">

### Author: ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)
#### Post date: [April 29, 2025, 7:28am UTC](https://forum.flowable.org/t/cmmn-query-for-multiple-business-keys-or-names/9502/9 "2025-04-29T07:28:07Z")

</div>

Hey @antonio.pascual,

No such functionality has not been added yet. If you are interested in it, you can provide a PR that will add it.

Cheers,  
Filip
