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

**URL:** <https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238>\
**Category:** Contributing\
**Created:** [September 24, 2020, 6:13am UTC](https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238 "2020-09-24T06:13:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikos](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@Nikos](https://forum.bpmn.io/u/Nikos)\
**Post date:** [September 24, 2020, 6:13am UTC](https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238/1 "2020-09-24T06:13:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![philippfromme](https://forum.bpmn.io/user_avatar/forum.bpmn.io/philippfromme/32/2803_2.png) [@philippfromme](https://forum.bpmn.io/u/philippfromme)\
**Post date:** [September 24, 2020, 7:04am UTC](https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238/2 "2020-09-24T07:04:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nikos](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@Nikos](https://forum.bpmn.io/u/Nikos)\
**Post date:** [September 24, 2020, 7:35pm UTC](https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238/3 "2020-09-24T19:35:01Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![philippfromme](https://forum.bpmn.io/user_avatar/forum.bpmn.io/philippfromme/32/2803_2.png) [@philippfromme](https://forum.bpmn.io/u/philippfromme)\
**Post date:** [September 25, 2020, 12:14pm UTC](https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238/4 "2020-09-25T12:14:36Z")

</div>

`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?

---

<div class="post-metadata">

**Author:** ![nikku](https://forum.bpmn.io/user_avatar/forum.bpmn.io/nikku/32/5130_2.png) [@nikku](https://forum.bpmn.io/u/nikku)\
**Post date:** [July 22, 2025, 3:34pm UTC](https://forum.bpmn.io/t/how-to-listen-when-a-task-is-deleted-inside-the-modeler/5238/5 "2025-07-22T15:34:35Z")

</div>

Closed on July 22, 2025, 3:34pm UTC


