How to create bpmn xml tags with sub-element


I want to create the following startEvent with outgoing and timeEventDefinition as sub element.

<bpmn:startEvent id="StartEvent_1y9irep">
      <bpmn:timerEventDefinition id="TimerEventDefinition_03yikjg" />

I’m creating startEvent as follows :

    let StartEvent = moddle.create('bpmn:StartEvent', {
        id: 'StartEvent_1y9irep',


which gives me

<bpmn2:startEvent id="StartEvent_1y9irep" />

How do i add outgoing and timeEventDefinition to startEvent.

Can you please help me with this.


What you’re basically doing is instantiating a new instance of bpmn:StartEvent. You’d need to instantiate and pass the bpmn:TimerEventDefinition, too.

Please check with bpmn-moddle, specifically the BPMN meta-model to learn which elements are allowed in a start event.

It will tell you that a bpmn:StartEvent is a bpmn:Event that contains a list of eventDefinitions. You’ll thus end up with something like this:

const event = moddle.create('bpmn:StartEvent', {
  eventDefinitions: [
    moddle.create('bpmn:TimerEventDefinition', { ... })
1 Like

Thank you :slight_smile: