Undo, redo with extension Elements


I’m facing challenges with undo, redo with extension elements, can you please suggest any example for undo, redo for extension elements.

What are the problems you’re facing?

the following issues currently facing

  • extension elements are not in in undo /redo flow.

I created the extension elements with the following way

const extensionElements = businessObject.extensionElements || moddle.create('bpmn:ExtensionElements');

Please let me know if you need more info ,
can you please suggest any working example for extension elements which have undo/redo flow

To guarantee a working undo/redo mechanism I’d always recommend to use commands. You could have a look on how we do it in the properties panel in some cases, with the underlying cmdHelper which uses the UpdateBusinessObjectHandler.

Attached is sample XML for Start element.

Start element has the 2 different types of extension elements , called
‘sample:properties’ and its child element ‘sample:property’

I’m using moddle.create API to create the ‘sample:properties’ , ‘sample:property’ . Once these elements are created , then pushing to the extension elements,

Using the following syntax for creating the bpmn:extension elements
const extensionElements = businessObject.extensionElements || moddle.create('bpmn:ExtensionElements');

when i wanted to update part of the extension elements ,i’m getting the existing bpmn:extension elements and updating the notation . xml generated as per the expectation, but when I do the Undo / Redo Operation ,old properties are similar to new properties

eg: for the first time when property desc is not present in extension elements, we are using
moddle.create and updating the bpmn extension elements , when desc is again updated with new value we are finding the existing ‘sample:property’ name with description and updating with new value
if we are updating property ‘desc’ with the values desc1 , desc2 , desc3 , desc4 , doing Undo operation showing only desc4 , when undoing multiple times property desc set to undefined

sampleXML.xml (753 Bytes)

When are you adding the extension elements? That is the actual question.

@philippfromme Thanks for the quick reply.

I show a property panel which is associated with every notation.
Whenever there is any change in the property panel values I call the function which executes the statements stated above.

Are you doing that using commands?

are you referring the CmdHelper ?

we are not using bpmn-property-panel , we are using own customized property panel.

can we use the CmdHelper for our customized property panel ?

Of course you can use it elsewhere

import CmdHelper from 'bpmn-js-properties-panel/lib/helper/CmdHelper';

Thank you for quick response