Custom attribute of element

Hello all
I have some issues. When i read attribute of element, i can’t read it with object type. For example

<bpmn:startEvent id=“StartEvent_1” objectData={object: {object}}>
</bpmn:startEvent>

I don’t know bpmn support save object type. Please help me.
- Expect: I want to save object data to element of bpmn

So you want to save JSON data in an XML file, is that correct?

1 Like

Yes. I want it. But you have best way to save data in element, please teach me.

Can you maybe share what you already tried to add your custom attribute inside a CodeSandbox?

I guess simply saving it as object won’t work. You will have to somehow serialize it, e.g. by saving it as String

const myObject = { foo: 'bar' };

const asString = JSON.stringify(myObject);

const asJSON = JSON.parse(asString);

Anyway, I would really recommend you to find a way to handle it the XML way. So instead of saving nested properties as JSON in a single attribute, try to save them as XML children.

For further assistance, please share a CodeSandbox that reproduces your issue in a way that we can inspect it.

The BPMN specification has a clearly defined extension mechanism. For complex data like JSON you should use bpmn:ExtensionElements that every BPMN element can have. To learn about how create your own extension have a look at this guide: bpmn-js-examples/custom-elements at master · bpmn-io/bpmn-js-examples · GitHub

Your resulting XML would like something like this:

<bpmn:startEvent id="StartEvent_1">
  <bpmn:extensionElements>
    <foo:data>{ foo: 'foo' }</foo:data>
  </bpmn:extensionElements>
</bpmn:startEvent>