I have an issue when trying to keep track of the BPMN elements added/removed in the diagram, specifically when using the Replace feature. Below is a description of the steps I’ve taken to reproduce the issue I’m having. Any help is much appreciated.
Drag a Task onto the designer
- Fires the shape.added event
***ID of element (Task) being added is “Task_1cgl3oq”
***I get basic info about the shape (including its ID) and record Task element in array of BPMN elements
Click on the Replace Context Menu Item of the Task (i.e. the Wrench icon), and change the Task to a Send Task
- Fires the shape.added event
***ID of element (Send Task) being added is “SendTask_126ged2"
***I get basic info about the shape (including its ID) and record Send Task element in array of BPMN elements based on the ID
***My array now has two elements “Task_1cgl3oq” and “SendTask_126ged2” - Fires the shape.removed event
***ID of element (Task) being removed is “Task_1cgl3oq”
***I remove the corresponding element from my array of BPMN elements
***My array now has one element “SendTask_126ged2”
Click on the Replace Context Menu Item of the Send Task (i.e. the Wrench icon), and change the Send Task to a Receive Task
- Fires the shape.added event
***ID of element (Receive Task) being added is “ReceiveTask_1u3a0h2”
***I get basic info about the shape (including its ID) and record Receive Task element in array of BPMN elements based on the ID
***My array now has two elements “SendTask_126ged2” and “ReceiveTask_1u3a0h2” - Fires the shape.removed event
***ID of element (Send Task) being removed is “Task_1cgl3oq”
***My code fails because there is no element with ID “Task_1cgl3oq” in my array
It seems that after the first Replace, after the shape.added and shape.removed code has finished running that the new Send Task has its ID changed back to the ID of the Task that was removed.