Adding Custom Attribute to BPMN Elements

Hello,

I want to add custom properties to my bpmn elements
I tried these codes

        var elementInfo : any = {};
        elementInfo.name ="Hüseyin";
        elementInfo.surname="Büyükdere";
        var elementRegistry = this.snaps.bpmDesigner.getDesignerInstance().get('elementRegistry');
        var elementr = elementRegistry.get(event.element.id);
        this.snaps.bpmDesigner.getDesignerInstance().get('modeling').updateProperties(elementr,elementInfo);

The code above adds to xml but when I import xml , cannot see anything.

var newCondition = moddle.create('bpmn:FormalExpression',{ body : JSON.stringify(elementInfo)});    
elementr.businessObject.elementInfo = newCondition;
    

The code above yes adds attribute to the element but doesnt exports to xml.

So
I want to add custome attributes about my businesss to elements . I need to export and import it with the custom attributes.

Please help me about it.

This is one of the most frequently asked question in this forum. Please make sure to use search for existing topics before opening new ones.

This example should help you: https://github.com/bpmn-io/bpmn-js-custom-elements-example

1 Like

Thanks for your speedly reply. I searched again. I used this https://forum.bpmn.io/t/problem-cannot-read-property-isgeneric-of-undefined/2755/4?u=hadi_jami . Thanks again.

1 Like