How do I put 'namespaced' attribute to moddle


#1

Hi, I’m doing this:

 this.element.businessObject.$attrs['camunda:candidateUsers'] = val;

and then this:

 var users = this.element.businessObject.$attrs['camunda:candidateUsers'];
 this.field.val(users);

this works but not before I load the xml created/ then the candidateUsers exist as a field in the businessObject, and the $attrs structure is empty.

Obviously I read and put attributes wrongly/ What would be the correct way?

Thankyou!


#2

This alone won’t save the camunda:candiateUsers entry to XML. The reason is, that you need to declare the camunda namespace, too:

this.element.businessObject.$attrs(
  'xmlns:camunda', 
  'http://camunda.org/schema/1.0/bpmn'
);

This is required to produce a valid BPMN 2.0 XML document.

The better alternative is to make bpmn-js aware of the camunda namespace and its attributes by including camunda-bpmn-moddle.

This way you can simply do the following:

this.element.businessObject.candiateUsers = 'a, b, c';