Is there an event that fires when a new process is created?

I am wondering whether there is an event that I could use to consistently determine whether a new process has been created (as a result of adding a Pool/Participant).

I naturally first tried to determine this based on the shape.added event for the element of type Participant. However, I ran into a couple of inconsistencies there.
Firstly, I am not quite sure what happens internally when the first participant is added. Does the previous process get deleted, and recreated, or does it simply get placed under the added participant? I have also noticed that the root.changed event fires when the first participant is added. What does that mean? I have also noticed that the id of the process does not change, which makes me think that the process itself does not change. When more participants are added, everything works fine, new processes are created for each new participant.

However, I have found an anomaly (possible bug?).

  • I start with a fresh model, the process has id Process_1
  • I add the first participant, the process still has id Process_1
  • I undo the action. The participant gets removed and the process still has id Process_1
  • I redo the undo. The first participant gets re-added, however the process now has a completely different id

This behaviour was totally unexpected and I am not quite sure how to interpret what is going on internally.

PS: for anyone wondering why I need the information about the process being created: I am creating an “extension” of the modeller for a custom modelling language. My modeller uses bpmn modeller to model part of my custom model. I am however using Blazor, so I have to transform the data model into C#. I use the events to synchronize my .NET data model in real time. All of the elements seem to work fine, but I hit this snag when I tried to add support for multiple processes in the form of participants.


From what I get, the first participant that’s added inherits the process ID from the Process, as it just encapsulates what was previously there:
recording (8)

Any other participant that’s added get’s a random ID, that’s also what happens when you redo the undo. Undo- and redo also seem to keep the ID when the participant is not empty, so this seems to be an edge case.


1 Like

Creating the first participant will change the root element of the diagram since a participant can only be a child of a collaboration, not a process. The existing process will be reused as the process referenced by the first participant. However, the redo behavior with the process having a different ID sounds like a bug. I can reproduce it. Would you mind opening an issue for that?

1 Like

Many thanks for your quick replies! I have opened the issue for the possible bug. Just to confirm - there is no specialized event that fires when a new process is created? I have hopefully found a solution that works, but it is not the most elegant way to do it, as I have to check for both root.added and element.added (of type participant) events. But hey, as long as it works.

You have to listen for both events, yes, but I wouldn’t say that it’s not elegant. :wink:

1 Like