The following code creates a timer with duration. However after the timer is created export does not work - the following exception is thrown
index.esm.js:709 Uncaught (in promise) TypeError: value.search is not a function
at BodySerializer.build (index.esm.js:709)
at eval (index.esm.js:874)
at forEach (index.esm.js:344)
at TypeSerializer.ElementSerializer.parseContainments (index.esm.js:868)
at TypeSerializer.ElementSerializer.build (index.esm.js:748)
at eval (index.esm.js:894)
....
const elementRegistry = bpmnJS.get("elementRegistry");
const bpmnFactory = bpmnJS.get("bpmnFactory");
const modeling = bpmnJS.get("modeling");
const task = elementRegistry.get("Activity_18o1v1u");
const event = modeling.createShape(
{
type: "bpmn:BoundaryEvent",
eventDefinitionType: "bpmn:TimerEventDefinition"
},
{ x: task.x, y: task.y },
task,
{ attach: true }
);
let businessObject = event.businessObject;
const eventDefinition = businessObject.eventDefinitions[0];
const timeDuration = ElementHelper.createElement(
"bpmn:FormalExpression",
{ body: 1000 },
eventDefinition,
bpmnFactory
);
eventDefinition.set("timeDuration", timeDuration);
Here is example: bpmn-js Sandbox (forked) - CodeSandbox