Search code examples
bpmncamundabpmn.iocamunda-modeler

How to get current Workflow XML for active Instance by the Rest API


In my AngularApp i will show the User the current Workflow, by using the REST API. No Problem so far, usnig:

GET /process-definition/{id}/xml

and the

bpmn.io Viewer.

But it's possible to highlight the current Task or get the special Instance of the Workflow, with highlight the current Task?

Thank you for your help.


Solution

  • 1. Get actual the task

    The call http://localhost:8080/engine-rest/task/?processInstanceId=<processInstanceId> return a json with the taskDefinitionKey.

    https://docs.camunda.org/manual/latest/reference/rest/task/get-query/

    2. Style the task

    You can add a style class and so highlight a task.

    viewer.importXML(diagramXML, function() {
        var canvas = viewer.get('canvas');
        canvas.addMarker('<<TaskId>>', 'highlight');
    });
    

    CSS for the color:

    .highlight:not(.djs-connection) .djs-visual > :nth-child(1) {
        fill: green !important; /* color elements as green */
    }
    

    The example is from https://github.com/bpmn-io/bpmn-js-examples/tree/master/colors#adding-colors