_createModdle error using ModelUtils.js is function

Hi all,

I am not able to use the “is” function of ModelUtils,js to get a specific node type array from a bpmn file, hope someone can help :slight_smile:

I started from the “bundling” example using the “pizza-collaboration.bpmn” and added my code inside the elementRegistry.filter function.

When I execute my code I have the following error message in the browser console:
“something went wrong: undefined Cannot read property ‘_createModdle’ of undefined”.

I run the app from VSCode, I first “compile” it with webpack and than run it with “npm run all”.

Here you can see my app.js code:

// we use stringify to inline an example XML document
import pizzaDiagram from '../resources/pizza-collaboration.bpmn';


// make sure you added bpmn-js to your your project
// dependencies via npm install --save bpmn-js
import BpmnViewer from 'bpmn-js';

// Custom line
import is from 'bpmn-js';
// END Custom line

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


viewer.importXML(pizzaDiagram).then(function(result) {

  const { warnings } = result;

  console.log('success !', warnings);

  viewer.get('canvas').zoom('fit-viewport');

  // Custom lines
  let elementRegistry = viewer.get('elementRegistry');  
  let elements = elementRegistry.filter(function (element) {
    return is(element, 'bpmn:Participant');
  });  
  // END - Custom lines

}).catch(function(err) {

  const { warnings, message } = err;

  console.log('something went wrong:', warnings, message);
});

Thanks

That won’t work, better use

import { is } from 'bpmn-js/lib/util/ModelUtil';

It worked.

Thank you so much!