How to set the value of the property panel programmatically?

For example, get or set the ID. Will I do this?
O%24%5BCJ)SOR0%5B~%5BL0%25YXYI59N
I now need to set ID and Name. What should I do? Thank you!

Hi @hyj,

if you want to change the properties of bpmn elements programmatically, you can do this by manipulating the xml. Check this to get an better understanding how bpmn.io handles XML imports.

Changing properties is possible using the modeling API that is being used by the properties panel as well:

modeling.updateProperties(myElement, {
  id: 'foo',
  name: 'Foo'
});

This will result in a command being executed that can be reverted.

Thanks, the problem has been solved

Hi @hyj,

happy to hear! Can you post your solution? Would be great to share your successful approach with the community.

OK, of course,Modify ID and name。

        let canvas = bpmnInstance.get('canvas ');
        let rootElement = canvas.getRootElement();
        var modeling = bpmnInstance.get('modeling');
        modeling.updateProperties(rootElement, {
          id: 'ABC',
          name: 'ABCD',
          isExecutable: true
        });
1 Like