Find Running Processes that have no Incidents

Hi all,
I am looking for a way to find all running processes for a specific user (I handle this via a Context Variable) But I only want processes without Incidents.
This is what I do right now:
final List processLst = runtimeService.createProcessInstanceQuery()
.variableValueEquals(ContextVariables.USER_ID.getName(), kundenNummer).list();

But this gives me processes with incidents also. So I could do this:
final List processLst = runtimeService.createProcessInstanceQuery()
.variableValueEquals(ContextVariables.USER_ID.getName(), kundenNummer).list();

But that gives me only processes with incidents… (where is the withoutIncidents() filter?)

The first query would not be too bad if I could find out if the ProcessInstance Object has an incident, but I dont know how to do hat.

any help on this is greatly apreciated.

Hi @Reinhard,

after checking the code here:,
you could try createProcessInstanceQuery().incidentId(null).

I havn’t tested this, but

hope this helps, Ingo


the createProcessInstanceQuery().incidentId(null) is probably not going to work as we check for the passed on id not to be null.

There is no withoutIncidents() option in the ProcessInstanceQuery yet. Since there also is no processInstanceIdNotIn() filter, one workaround here could be to

  1. fetch the instances with incidents,
  2. fetch all instances,
  3. extract those instances from the second list that are not in the first list.

It is far from ideal, I admit.

You are very welcome to submit a feature request for both filter options in the ProcessInstanceQuery if you like. You can use our Issue Tracker for that.


thanks for the reply. You are right, die query createProcessInstanceQuery().incidentId(null) does not work as you mentioned.
Despite the not existing query options I ask myself, why can I not say if a processInstance has an incident or not. Shouldn’t that be possible?

If I do this:
final List<ProcessInstance> processLst = runtimeService.createProcessInstanceQuery() .active() .variableValueEquals(ContextVariables.USER_ID.getName(), kundenNummer).list();

There is, as far as I know, no way to tell if the processInstances in that list have incidents or not. I think that should really be possible.

Right now I came up with the same, far from optimal, solution of doing two queries and merge the result of that two.


Hi Reinhard,

the inclusion of a withoutIncidents() option in the ProcessInstanceQuery makes total sense as far as I’m concerned.

However, I don’t see that much benefit in including such a flag in the ProcessInstance entity itself if there is an option in the query.
Furthermore, it would also bloat the process instance with information that might be out-of-date moments after you fetched it because this aspect is something that might change anytime. Other data resembled in the process instance is mostly (not entirely though) data that is fixed for that instance.
Beyond that, it also introduces technical drawbacks as the information is spread across multiple tables in the database.
This is however just my personal view on this.

TL;DR: I would opt for a query option withoutIncidents() for the ProcessInstanceQuery here.

Hope that helps.

As I said, we always appreciate feature request for such things. :slight_smile: