Search code examples
camunda

Retrieving a process Instance diagram in Camunda


I have been trying to retrieve a process instance diagram from Camunda engine. All the JAVA and REST methods deal with retrieving the deployed process diagram. So, the closest I am is this method.

InputStream getProcessDiagram(String processDefinitionId) 

But its of no use to me as I want to be able to get the current state of the particular process instance.

The process diagram representing the current state can be viewed in Camunda Tasklist but I have no clue as to how to retrieve it.

Thanks!


Solution

  • The diagram with its state does not simply come from the REST API as is. Instead, data from two sources is collected:

    • GET /process-definition/{id}/xml provides the BPMN diagram (which you have already found) [1]
    • GET /process-instance/{id}/activity-instances provides the state of a process instance in a tree structure [2]

    The tasklist has some client-side logic that renders the BPMN XML with bpmn.io and places markers on top of it based on the activity instance tree.