# How to remove connection programmically?

**URL:** <https://forum.bpmn.io/t/how-to-remove-connection-programmically/7882>\
**Category:** General\
**Created:** [August 17, 2022, 3:46pm UTC](https://forum.bpmn.io/t/how-to-remove-connection-programmically/7882 "2022-08-17T15:46:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![A\_M](https://forum.bpmn.io/user_avatar/forum.bpmn.io/a_m/32/3813_2.png) [@A\_M](https://forum.bpmn.io/u/A_M)\
**Post date:** [August 17, 2022, 3:46pm UTC](https://forum.bpmn.io/t/how-to-remove-connection-programmically/7882/1 "2022-08-17T15:46:01Z")

</div>

I want to remove connection programmically with its `id`. Not clicking trash icon.  
In the example: [GitHub - bpmn-io/bpmn-js-example-custom-shapes: Creating custom elements in bpmn-js that live outside a BPMN 2.0 diagram.](https://github.com/bpmn-io/bpmn-js-example-custom-shapes)

---

<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:** [August 24, 2022, 12:50pm UTC](https://forum.bpmn.io/t/how-to-remove-connection-programmically/7882/2 "2022-08-24T12:50:11Z")

</div>

[`Modeling#removeElements`](https://github.com/bpmn-io/diagram-js/blob/develop/lib/features/modeling/Modeling.js#L377) is your friend.

```javascript
bpmnjs.get('modeling').removeElements([ 
  bpmnjs.get('elementRegistry').get('foo')
]);

```

---

<div class="post-metadata">

**Author:** ![system](https://forum.bpmn.io/uploads/default/original/2X/b/b534893973385c2d302b38572464112e4adae002.png) [@system](https://forum.bpmn.io/u/system)\
**Post date:** [August 31, 2022, 12:50pm UTC](https://forum.bpmn.io/t/how-to-remove-connection-programmically/7882/3 "2022-08-31T12:50:12Z")

</div>

Closed on August 31, 2022, 12:50pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
