How to get all the running process instances

Hi, I am new to Flowable and I need to query all the running process instances that were started over a X period of time. For example, I want to query the process instances that are “older” than 15 days. How can I achieve this?

Thank you

Just have a look at the documentation until the “Query” chapter:

Something like:

ProcessEngine processEngine = // get engine instance
List<ProcessInstance> result = processEngine.getRuntimeService()
.createProcessInstanceQuery()
.startedBefore(/*date*/)
.list()

Hi Arthur! Thank you for replying. This is what I needed it. One more question,

If I also want to query the list of running processes that started before a given date AND also
contain an execution variable named “isValidUntilDate” of type Date whose value is a date has passed. Do I need to create a native query for this intend? or is there a way to achieve this using the Query API similarly?

Thank you in advance!

This should be possible with the “variableValue**” or “scopedVariableValue**” query methods.

List<ProcessInstance> result = processEngine.getRuntimeService()
.createProcessInstanceQuery()
.startedBefore(/*date*/)
.variableValueGreaterThanOrEqual("isValidUntilDate", new Date())
.list()

Best, Arthur