Hi there,
I’m looking for a way to find currentTask for a list of processInstanceId.
https://forum.camunda.io/t/taskquery-for-tasks-of-several-processes/6759
I watched this post and solutions who were submitted but nothing works.
tasks = _taskService.createTaskQuery()
.or().processInstanceId(processIds[0]).endOr()
.or().processInstanceId(processIds[1]).endOr()
.or().processInstanceId(processIds[2]).endOr()
.initializeFormKeys()
.list();
This solution doesn’t work because between each “.or()”, engine will use “AND”. And use only one “or()” doesn’t work neither because each processInstanceId will be replaced by the next one.
Right now, I’m using NativeQuery but I’m looking for a standard way to do it.
StringBuilder sb = new StringBuilder();
sb.append("SELECT * FROM ACT_RU_TASK ");
sb.append(" WHERE ");
sb.append(StreamUtil.streamopt(processInstanceIds).map(a -> "(PROC_INST_ID_ ='" + a + "')").collect(Collectors.joining(" OR ")));
return taskService.createNativeTaskQuery().sql(sb.toString()).list();
In my opinion, best solution would be to add “processInstanceIdIn(…)” in taskQuery. Is there another way than NativeQuery right now ? (I’m using Camunda 7.12)
Thanks a lot,