How to get bpmn file from js?


#1

Hi all.

Is it possible to get string with XML-content of current BPMN diagram directly in JS-code?

Thanks


#2

Hey @coriolis2003,

yes it is possible. If you have instanciated bpmn-js, you can get the xml using the method saveXML:

var BpmnViewer = require('bpmn-js');

var viewer = new BpmnViewer({ container: '#canvas' });

viewer.importXML(pizzaDiagram, function(err) {

  if (!err) {
    viewer.saveXML({ format: true }, function(err, xml) {
      // log the current xml content to the browser console
      console.log(xml);
    });
  } else {
    console.log('something went wrong:', err);
  }
});

This snippet is based on the simple-commonjs Example.


#3

Is it possible to use viewer to edit elements label for example change “Select A Pizza” to “Order A Pizza” and change “Order A Pizza” to “Eat A Pizza” then save the xml ?


#4

The Viewer is intended to be used for viewing a process. If you want do do modeling you have to use the Modeler. Have a look at this example.


#5

Hi Phillippfromme,
Thanks for replying to my question. I really need automation. The basic premises of what I am, trying to accomplish is I create a bpmn file, then load it into viewer for the user to review online. I want the user to track the status of the task and each task to update their status from “Select A Pizza” to “Order A Pizza” then have the user to check each time a status was updated. The user can also save this file each time it has been updated… Let me know that made any sense …thanks again