How to create bpmn xml tags with sub-element

Hi,

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

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

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.

Regards,
Pratik

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:

I have found there are no RegisterStartEvent in BPMN meta-model, how can I add this event type?

Please do not necrobump old topics. Instead link to this thread from new topic.