How to add a timeDuration to a timerEventDefinition

Hey,
I try to implement a vue version of the property panel (https://github.com/bpmn-io/bpmn-js-properties-panel). Atm I am working on the TimerEventDefinition. I am able to create this definition with:

const element = modeler.get("elementRegistry").get(validElementId);
const bpmnFactory = modeler.get("bpmnFactory");

const eventDefinition = bpmnFactory.create("bpmn:TimerEventDefinition");
element.businessObject.eventDefinitions = [eventDefinition];
eventDefinition.$parent = element.businessObject;

But I wonder how I am able to add <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">definitionValue</bpmn:timeDuration> part to the eventDefintion properly.

I read the properties-panel code, but I dont find the “place” where timeDuration is added to the eventDefinition. There is only one place in TimerEventDefinition.js where timeDuration (newType) is added as property:

props[newType] = createFormalExpression(timerEventDefinition, value, bpmnFactory);
...
return cmdHelper.updateBusinessObject(element, timerEventDefinition, props);

But I don’t know if its the place where the needed magic happens, cause I think the timeDuration should be added like in the first eventDefinition code snipped above (create and set proper parent)

Also I wonder how I am able to add this xsi:type. Do I have to or is it added automatically by the moddle lib somehow?

Thnx
Alex

I was able to solve the issue. I just had to set the timeDefinition properly:

const timeDefinition = createFormalExpression(eventDefinition, 'test', bpmnFactory);
eventDefinition.set('timeDuration', timeDefinition);
1 Like