When deleting Participant all custom values on the Process element get lost

When we delete the Participant element from the diagram the Process element seem to get recreated with some default values. All custom values get lost. Even custom elements inside extensionElements are lost.

How to reproduce:

  • Open online modeler https://demo.bpmn.io/new
  • Open this simple XML that has a Process element with a custom value in the Id attribute
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1dwi72d" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_CustomId">
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_CustomId">
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

  • Drag a Participant element from the toolbar to the diagram
  • Delete the newly created Participant element
  • Download the diagram via “Download BPMN diagram” button
  • Open downloaded XML and observe that the process Id has changed
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" id="Definitions_1dwi72d" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_0jenv2z" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0jenv2z" />
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

As of now this is the expected behavior. Deleting the last remaining participant will turn the collaboration into a process, adding a participant will do the opposite. By replacing the root element with the ID will change. Feel free to create a feature request in the corresponding repository if you’d want this to change.

We need a workaround for this so that we preserve all process attributes when removing the Participant element. What is the best way for us to achieve this?
I was thinking of reading all Process attributes when the Participant element is removed and then add all this attributes to the newly created Process element. But I’m not really sure when should I add this attributes.

Here is what I had in mind:

eventBus.on("shape.removed", function (event) {
            if (event.element.type=== "bpmn:Participant") {
                // Read all process attributes that should be added to the new process once created.
                var oldProcess = event.element.businessObject.processRef;
            } 
        });

This behavior is currently implemented in the RemoveParticipantBehavior. If you want to prepare a feature that you requested, you could start in that place. Feel free also to create a feature request on GitHub via the link posted by @philippfromme.

1 Like