Error when using the modeler

Hello, I’m rather new to BPMN.io and I’ve got this error when running my code. I don’t really know how to solve it as I believe everything should be working correctly within my code.

The whole error mesage is this:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘bpmnElement’)
at getDiagramsToImport (bpmn-modeler.development.js:16886:41)
at render (bpmn-modeler.development.js:16825:30)
at bpmn-modeler.development.js:16856:9
at new Promise ()
at importBpmnDiagram (bpmn-modeler.development.js:16847:12)
at Modeler.open (bpmn-modeler.development.js:17394:32)
at Modeler.importDefinitions (bpmn-modeler.development.js:17333:31)
at Modeler.importXML (bpmn-modeler.development.js:17282:39)

Everything seems to happen within the library and I’m a bit lost on what to do. My code generates the diagram dynamically using an excel and some C# code to transform the excel into something the library can run.

<?xml version="1.0" encoding="UTF-8"?>

<bpmn:definitions xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:bpmn=“http://www.omg.org/spec/BPMN/20100524/MODEL” id=“Definitions_1” targetNamespace=“http://bpmn.io/schema/bpmn”>
<bpmn:process id=“Process_1” isExecutable=“false”>
<bpmn:startEvent id=“inicio” name=“Inicio”></bpmn:startEvent>
<bpmn:endEvent id=“fin” name=“Fin”></bpmn:endEvent>
<bpmn:exclusiveGateway id=“10” name=“¿Proveedor Homologado?”></bpmn:exclusiveGateway>
<bpmn:task id=“20” name=“Solicitud de datos”></bpmn:task>
<bpmn:task id=“30” name=“Solicitar Cuestionario”></bpmn:task>
<bpmn:task id=“40” name=“Evaluación Product Manager”></bpmn:task>
<bpmn:task id=“50” name=“Evaluación Purchasing Engineer”></bpmn:task>
<bpmn:exclusiveGateway id=“OR_60” name=“OR60”></bpmn:exclusiveGateway>
<bpmn:exclusiveGateway id=“60” name=“Revisar aprobación de las evaluaciones”></bpmn:exclusiveGateway>
<bpmn:exclusiveGateway id=“70” name=“Meeting revisión evaluaciones con partes implicadas”></bpmn:exclusiveGateway>
<bpmn:task id=“80” name=“Solicitamos muestras de producto”></bpmn:task>
<bpmn:exclusiveGateway id=“90” name=“Evaluación de muestras”></bpmn:exclusiveGateway>
<bpmn:task id=“100” name=“Homologamos producto”></bpmn:task>
<bpmn:task id=“110” name=“Descartamos Producto / Proveedor / Servicio”></bpmn:task>
<bpmn:sequenceFlow id=“enlace_1020” sourceRef=“10” targetRef=“20”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_1030” sourceRef=“10” targetRef=“30”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_20_AND_40” sourceRef=“20” targetRef=“AND_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_30_AND_40” sourceRef=“30” targetRef=“AND_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_4040” sourceRef=“AND_40” targetRef=“40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_20_AND_50” sourceRef=“20” targetRef=“AND_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_30_AND_50” sourceRef=“30” targetRef=“AND_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_5050” sourceRef=“AND_50” targetRef=“50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_40_OR_60” sourceRef=“40” targetRef=“OR_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_50_OR_60” sourceRef=“50” targetRef=“OR_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_OR_6060” sourceRef=“OR_60” targetRef=“60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_6070” sourceRef=“60” targetRef=“70”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_60_AND_80” sourceRef=“60” targetRef=“AND_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“elnace_70_AND_80” sourceRef=“70” targetRef=“AND_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_8080” sourceRef=“AND_80” targetRef=“80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_8090” sourceRef=“80” targetRef=“90”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“fin100” sourceRef=“100” targetRef=“fin”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_90100” sourceRef=“90” targetRef=“100”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“fin110” sourceRef=“110” targetRef=“fin”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_70110” sourceRef=“70” targetRef=“110”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_90110” sourceRef=“90” targetRef=“110”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_inicio” sourceRef=“inicio” targetRef=“10”></bpmn:sequenceFlow>
</bpmn:process>
</bpmn:definitions>

Right now that’s the whole value of my BPMN but the error keeps popping out and I don’t know how to solve it.

Did you validate your diagram against the BPMN 2.0 XML schema using an XSD validator to determine if it is valid BPMN? I’d consider you to do it to prevent silly mistakes such as malformed xsd:id elements (numbers only).

Once everything is :white_check_mark: there you can check the diagram for import errors and warnings, cf. bpmn-js usage.

But really, your first “quality gate” should be a passing XSD schema validation (against the BPMN 2.0 XML schema).

First of all thank you for answering.

Now, I tried using an XML validator and it said everything was fine. I already installed everything with the prepackage version so there is no error with the imports and yet the same error keeps happening “Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘bpmnElement’)”. If you have any other ideas as to why this happens I would appreciate it.

image

Now, I tried using an XML validator and it said everything was fine.

I’ve used this online validator and can confirm that validation works just fine, if you attach the BPMN schema inside an xsi:schemaLocation attribute. This is what I indicated earlier, this is what the validator tells you about. Of course your diagram is structural valid XML, that does not make it a valid BPMN 2.0 document.

Example diagram I used:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd http://www.omg.org/spec/DD/20100524/DC https://www.omg.org/spec/BPMN/20100501/DC.xsd http://www.omg.org/spec/BPMN/20100524/DI https://www.omg.org/spec/BPMN/20100501/BPMNDI.xsd http://www.omg.org/spec/DD/20100524/DI https://www.omg.org/spec/BPMN/20100501/DI.xsd" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:startEvent id="StartEvent_1" />
    <bpmn:task id="Task_1" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="173" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
        <dc:Bounds x="353" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Copy the xsi:schemaLocation and xmlns:xsi attribute over to your files to get BPMN validation.

I already installed everything with the prepackage version so there is no error with the imports

Did you check if there is warnings with the imports? Using your diagram in another tool I see tons of warnings.

Yes I checked both in the code, no warnings nor indications of any problem, and in the browser console, no warnings or indications of problems with the imports.

image
image

Using the online editor I’ve noticed that the problem may be in the way I name my tasks, gates and flows. Because it seems it is not accepted by the editor. Thank you for answering again and sorry for bothering it’s my first time using this library and I’m a bit green on the edges

Let me share some things that I see (testing against the online editor at demo.bpmn.io and an XSD schema validator).

Online editor

I see no diagram to display as an import error:

image

In the developer console (F12) I see tons of additional import warnings, hinting that IDs have an illegal format:

image

In the XSD schema validator

At the same time, applying my previous hint to your diagram and piping it through an BPMN 2.0 schema (XSD) validator:

image


At this stage I’m not sure what you’re doing differently.

Helo, thanks for answering again. The ID things you mentioned I’ve already checked and I think I solved it, my new XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<bpmn:definitions
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xmlns:bpmn=“http://www.omg.org/spec/BPMN/20100524/MODEL” id=“Definitions_1” targetNamespace=“http://bpmn.io/schema/bpmn”>
<bpmn:process id=“Process_1” isExecutable=“false”>
<bpmn:startEvent id=“inicio” name=“Inicio”></bpmn:startEvent>
<bpmn:endEvent id=“fin” name=“Fin”></bpmn:endEvent>
<bpmn:exclusiveGateway id=“a_10” name=“¿Proveedor Homologado?”></bpmn:exclusiveGateway>
<bpmn:task id=“a_20” name=“Solicitud de datos”></bpmn:task>
<bpmn:task id=“a_30” name=“Solicitar Cuestionario”></bpmn:task>
<bpmn:parallelGateway id=“a_AND_40” name=“AND40”></bpmn:parallelGateway>
<bpmn:task id=“a_40” name=“Evaluación Product Manager”></bpmn:task>
<bpmn:parallelGateway id=“a_AND_50” name=“AND50”></bpmn:parallelGateway>
<bpmn:task id=“a_50” name=“Evaluación Purchasing Engineer”></bpmn:task>
<bpmn:exclusiveGateway id=“a_OR_60” name=“OR60”></bpmn:exclusiveGateway>
<bpmn:exclusiveGateway id=“a_60” name=“Revisar aprobación de las evaluaciones”></bpmn:exclusiveGateway>
<bpmn:exclusiveGateway id=“a_70” name=“Meeting revisión evaluaciones con partes implicadas”></bpmn:exclusiveGateway>
<bpmn:parallelGateway id=“a_AND_80” name=“AND80”></bpmn:parallelGateway>
<bpmn:task id=“a_80” name=“Solicitamos muestras de producto”></bpmn:task>
<bpmn:exclusiveGateway id=“a_90” name=“Evaluación de muestras”></bpmn:exclusiveGateway>
<bpmn:task id=“a_100” name=“Homologamos producto”></bpmn:task>
<bpmn:task id=“a_110” name=“Descartamos Producto / Proveedor / Servicio”></bpmn:task>
<bpmn:sequenceFlow id=“enlace_1020” sourceRef=“a_10” targetRef=“a_20”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_1030” sourceRef=“a_10” targetRef=“a_30”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_20_AND_40” sourceRef=“a_20” targetRef=“a_AND_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_30_AND_40” sourceRef=“a_30” targetRef=“a_AND_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_4040” sourceRef=“a_AND_40” targetRef=“a_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_20_AND_50” sourceRef=“a_20” targetRef=“a_AND_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_30_AND_50” sourceRef=“a_30” targetRef=“a_AND_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_5050” sourceRef=“a_AND_50” targetRef=“a_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_40_OR_60” sourceRef=“a_40” targetRef=“a_OR_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_50_OR_60” sourceRef=“a_50” targetRef=“a_OR_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_OR_6060” sourceRef=“a_OR_60” targetRef=“a_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_6070” sourceRef=“a_60” targetRef=“a_70”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_60_AND_80” sourceRef=“a_60” targetRef=“a_AND_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_70_AND_80” sourceRef=“a_70” targetRef=“a_AND_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_8080” sourceRef=“a_AND_80” targetRef=“a_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_8090” sourceRef=“a_80” targetRef=“a_90”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“fin100” sourceRef=“a_100” targetRef=“fin”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_90100” sourceRef=“a_90” targetRef=“a_100”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“fin110” sourceRef=“a_110” targetRef=“fin”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_70110” sourceRef=“a_70” targetRef=“a_110”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_90110” sourceRef=“a_90” targetRef=“a_110”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_inicio” sourceRef=“inicio” targetRef=“a_10”></bpmn:sequenceFlow>
</bpmn:process>
</bpmn:definitions>

I tried validating it in different XML validators and they always say it’s valid but when I try to use it on the online editor of BPMN-js no diagram is shown.

The difference now is that there is no “error” so I don’t know what to do now. Could you tell me any ideas of what I’m doing wrong? The same problem keeps showing in the developer console no matter what I change in the XML

image

Thank you beforehand

Well well, now you need to add a DI section, cf. my example. The DI section defines how the process (that you now defined in a sound manner) is displayed.

Basically a list of shapes and connections, with their waypoints, referencing the actuall process elements:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd http://www.omg.org/spec/DD/20100524/DC https://www.omg.org/spec/BPMN/20100501/DC.xsd http://www.omg.org/spec/BPMN/20100524/DI https://www.omg.org/spec/BPMN/20100501/BPMNDI.xsd http://www.omg.org/spec/DD/20100524/DI https://www.omg.org/spec/BPMN/20100501/DI.xsd" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
  <!-- the semantic process -->
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:startEvent id="StartEvent_1" />
  </bpmn:process>
  <!-- defines display of process -->
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <!-- a "diagram to display" -->
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <!-- a shape on the canvas -->
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="173" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Hello. I’ve been trying to solve the error but I don’t know what’s wrong anymore. I added the DI section you mentioned yet I still get the same error.

<?xml version="1.0" encoding="UTF-8"?>

<bpmn:definitions xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:bpmn=“http://www.omg.org/spec/BPMN/20100524/MODEL” xmlns:bpmndi=“http://www.omg.org/spec/BPMN/20100524/DI"xmlns: di = “http://www.omg.org/spec/DD/20100524/DI” xmlns:dc=“http://www.omg.org/spec/DD/20100524/DC” id=“Definitions_1” targetNamespace=“http://bpmn.io/schema/bpmn”>
<bpmn:process id=“Process_1” isExecutable=“false”>
<bpmn:startEvent id=“inicio” name=“Inicio”></bpmn:startEvent>
<bpmn:endEvent id=“fin” name=“Fin”></bpmn:endEvent>
<bpmn:exclusiveGateway id=“a_10” name=”¿Proveedor Homologado?"></bpmn:exclusiveGateway>
<bpmn:task id=“a_20” name=“Solicitud de datos”></bpmn:task>
<bpmn:task id=“a_30” name=“Solicitar Cuestionario”></bpmn:task>
<bpmn:parallelGateway id=“a_AND_40” name=“AND40”></bpmn:parallelGateway>
<bpmn:task id=“a_40” name=“Evaluación Product Manager”></bpmn:task>
<bpmn:parallelGateway id=“a_AND_50” name=“AND50”></bpmn:parallelGateway>
<bpmn:task id=“a_50” name=“Evaluación Purchasing Engineer”></bpmn:task>
<bpmn:exclusiveGateway id=“a_OR_60” name=“OR60”></bpmn:exclusiveGateway>
<bpmn:exclusiveGateway id=“a_60” name=“Revisar aprobación de las evaluaciones”></bpmn:exclusiveGateway>
<bpmn:exclusiveGateway id=“a_70” name=“Meeting revisión evaluaciones con partes implicadas”></bpmn:exclusiveGateway>
<bpmn:parallelGateway id=“a_AND_80” name=“AND80”></bpmn:parallelGateway>
<bpmn:task id=“a_80” name=“Solicitamos muestras de producto”></bpmn:task>
<bpmn:exclusiveGateway id=“a_90” name=“Evaluación de muestras”></bpmn:exclusiveGateway>
<bpmn:task id=“a_100” name=“Homologamos producto”></bpmn:task>
<bpmn:task id=“a_110” name=“Descartamos Producto / Proveedor / Servicio”></bpmn:task>
<bpmn:sequenceFlow id=“enlace_1020” sourceRef=“a_10” targetRef=“a_20”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_1030” sourceRef=“a_10” targetRef=“a_30”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_20_AND_40” sourceRef=“a_20” targetRef=“a_AND_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_30_AND_40” sourceRef=“a_30” targetRef=“a_AND_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_4040” sourceRef=“a_AND_40” targetRef=“a_40”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_20_AND_50” sourceRef=“a_20” targetRef=“a_AND_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_30_AND_50” sourceRef=“a_30” targetRef=“a_AND_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_5050” sourceRef=“a_AND_50” targetRef=“a_50”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_40_OR_60” sourceRef=“a_40” targetRef=“a_OR_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_50_OR_60” sourceRef=“a_50” targetRef=“a_OR_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_OR_6060” sourceRef=“a_OR_60” targetRef=“a_60”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_6070” sourceRef=“a_60” targetRef=“a_70”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_60_AND_80” sourceRef=“a_60” targetRef=“a_AND_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_70_AND_80” sourceRef=“a_70” targetRef=“a_AND_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_AND_8080” sourceRef=“a_AND_80” targetRef=“a_80”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_8090” sourceRef=“a_80” targetRef=“a_90”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“fin100” sourceRef=“a_100” targetRef=“fin”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_90100” sourceRef=“a_90” targetRef=“a_100”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“fin110” sourceRef=“a_110” targetRef=“fin”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_70110” sourceRef=“a_70” targetRef=“a_110”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_90110” sourceRef=“a_90” targetRef=“a_110”></bpmn:sequenceFlow>
<bpmn:sequenceFlow id=“enlace_inicio” sourceRef=“inicio” targetRef=“a_10”></bpmn:sequenceFlow>
</bpmn:process>
</bpmn:definitions>

I now know that my error happens when I call the viewer library. Would you know what exactly I’m doing wrong? Because I added the DI section and yet I’m not getting any result. Sorry for bothering you again.

image

Also, when I try to run the XML in the online editor I get this, which I get is the DI section:

image

@Ewent You’d want to read my comments more carefully. If I share a full BPMN diagram with a working bpmndi section I’d expect you to show me how your diagram contains such section.

Consider reviewing my previous comments and see what is going on in your diagram. Use the techniques you already learned (check XSD schema validation, import errors, …) to pin down your issue.