How to get a list of components in the diagram


I need to get all the components used in the diagram because I have to get all the UserTask in order to retrieve all the extensionElements for each of them.

Is there a formal way within the bpmn-js to do so?

Thank you

Hey @rbatllet, welcome to our forum!

You can query all elements using the elementRegistry. It also has a filter function, which you can use to get all elements. If you only want a specific type of elements, you can use the is helper function like that:

var elements = elementRegistry.filter(function(element) {
  return is(element, 'bpmn:UserTask');
1 Like

Thank you very much… and another question… to get all the used components it is correct to do this?:

        return element;

Basically yes. But we also have a shortcut function called elementRegistry.getAll():

I am very grateful for the answer.