How to listen when a task is deleted inside the Modeler?

Hello all,

I try to figure out how could I possibly get a deletion event, once a task is deleted in the Modeler.

For example, when a task is added, I use the following code and log the element on the console.
eventBus.on(“shape.added”, function (event) {
const element = event.element,
businessObject = element.businessObject;
if (businessObject.$instanceOf(“bpmn:Task”)) {
console.log(element);
}
});

How can I change the code above, to console.log the element that was deleted?

Thank you all in advacne.

Regards,
Nick.

1 Like

You can listen to shape.remove (before removal) and shape.removed (after removal).

@philippfromme Hey Philipp,
thanks for your answer.

Actually, I want only to listen to a task removal.

So, the shape.removal listens to also to the change of the task type.
Can I somehow disable this?

I want only to listen to a complete removal of a task and not to its type change.

Thank you in advance.

shape.remove(d) is only fired when a shape is removed. When you change the type of a task through the context menu what happens is that the current task will be removed and a new task with the chosen type will be added at the same position.

Can you explain what your use case is?