How to replace a DataObject element


I’m having a hard time replacing an existing [DataObject] referenced in a [DataObjectReference] item. Here is what i’m doing:

//create new [DataObject] element
var dataObject = moddle.create("bpmn:DataObject"); = "ID_dataObject"; = "name_dataObject";

//set up properties to update on [DataObjectReference] element
var property = {
	dataObjectRef: dataObject, //replace [DataObject] element
	id: "ID_dataObjectRef",    //update ID of [DataObjectReference] element
	name: "name_dataObjectRef" //update Name of [DataObjectReference] element

//update actual [DataObjectReference] element
modeling.updateProperties(dataObjectReferenceElement, property);

The resulting XML is this:

<bpmn:dataObjectReference id="ID_dataObjectRef" name="name_dataObjectRef" dataObjectRef="ID_dataObject" />
<bpmn:dataObject id="DataObject_02e32s8" />

The new [DataObject] element is not present in the XML.


Hey @ThePasko,

does your code produce any errors? It should fail because you should use
modeling.updateProperties instead of

or is it just a typo in your forum post?


Yes it was a typo. I edited my post. Thanx.


Hey @ThePasko,

I figured out, what the problem is. It is not sufficient to just create the data object, it also has to be added to a parent, if it should be included in the XML. I added a test case in bpmn-moddle to demonstrate that case:

If you want undo/redo support in addition, you also have to take care of this yourself. To find out how that is done, check this post: Update custom BPMN meta data so it can be undone via CTRL+Z

Hope that helps :slightly_smiling: