Get nodes (past, present and future) in chronological order via REST API


#1

Hello friendly camunda community,

Is there a way to get a list of the nodes in a process by instance ID in chronological order (combined view of history and not yet visited)?

I’m currently using the REST API (more specifically GET /history/activity-instance) to retrieve a list of already visited nodes but the order is a bit counter intuitive (it makes sense if you know how the engine is implemented but, from an outside perspective, you would expect the nodes to be returned in the order they appear in the process definition).

In addition, the available sorting parameters (sortBy and sortOrder) seem to be pretty much tied to the internal implementation which again leads to a counter intuitive result (e.g. order by end date leads to the end event being returned before the last activity in the process).

Looking forward to your replies!

Best,
Nils


#2

If you want to get the “possible” order you need to get the XML of the process def and traverse the model.

When using the activity-instance history you need to sort: not sure if it is implemented in the Rest API, but when sorting you would need to implement: https://docs.camunda.org/javadoc/camunda-bpm-platform/7.9/org/camunda/bpm/engine/history/HistoricActivityInstanceQuery.html#orderPartiallyByOccurrence() if you wanted the true “order in which they occurred”.

you can see a example of usage for sorting here: https://github.com/DigitalState/camunda-coverage-generation-groovy/blob/master/src/main/groovy/io/digitalstate/camunda/coverage/bpmn/CoverageBuilder.groovy#L64

If you want to know the possible pathways a task can take, you would need to do something like: Get / Preview next task


Is there a way can get the execution path of historic activities?