# Import a flow containing a subflow without unintentionally creating a duplicate subflow

**URL:** <https://discourse.nodered.org/t/import-a-flow-containing-a-subflow-without-unintentionally-creating-a-duplicate-subflow/15683>\
**Category:** Feature Requests\
**Created:** [19 September 2019 05:31 UTC](https://discourse.nodered.org/t/import-a-flow-containing-a-subflow-without-unintentionally-creating-a-duplicate-subflow/15683 "2019-09-19T05:31:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cuxcrider](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@cuxcrider](https://discourse.nodered.org/u/cuxcrider)\
**Post date:** [19 September 2019 05:31 UTC](https://discourse.nodered.org/t/import-a-flow-containing-a-subflow-without-unintentionally-creating-a-duplicate-subflow/15683/1 "2019-09-19T05:31:18Z")

</div>

I need to copy/paste a flow that contains a subflow. However, when I do this, nodered creates an identical subflow but appends (2) or (3) or (4), etc. to the end of the subflow name. So far I determined a very basic test subflow does not behave like this, but once I include an mqtt node, I get this behavior. I have an example flow below.

Take the example flow, import it, then import it again and you should find yourself with a subflow called 'test subflow' and another one called 'test subflow (2)'. You can try just deleting the mqtt node and then repeating this process and you will not get 'test subflow (2)', you will only have 'test subflow'.

I am seeing that node-red automatically renames the subflow and changes the id of the subflow. I'm just not sure what triggers the conflict when it imports it. Apparently having an mqtt node does this, but just having the function node does not.

\*note: this flow does not really do anything, it's just a quick way to demonstrate the issue. thanks for your help!

```auto
[{"id":"df115b21.a9c4f8","type":"subflow","name":"test subflow","info":"","category":"","in":[{"x":562.9999942779541,"y":249.0000114440918,"wires":[{"id":"388c98ef.3128e8"}]}],"out":[{"x":847.9999980926514,"y":245.99999618530273,"wires":[{"id":"388c98ef.3128e8","port":0}]}],"env":[]},{"id":"ad02fcde.0f788","type":"comment","z":"df115b21.a9c4f8","name":"test subflow import","info":"test subflow import","x":738.0234298706055,"y":127.05468368530273,"wires":[]},{"id":"388c98ef.3128e8","type":"function","z":"df115b21.a9c4f8","name":"hello","func":"msg.payload = \"hello\"\nreturn msg;","outputs":1,"noerr":0,"x":705.7734375,"y":246.203125,"wires":[[]]},{"id":"5b73054.8c7c8fc","type":"mqtt in","z":"df115b21.a9c4f8","name":"","topic":"test","qos":"2","datatype":"auto","broker":"547471b5.d339","x":544.7734603881836,"y":339.32031631469727,"wires":[["388c98ef.3128e8"]]},{"id":"547471b5.d339","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"dc3259b7.f5bd38","type":"tab","label":"test main flow","disabled":false,"info":""},{"id":"5073cfef.7fabf","type":"subflow:df115b21.a9c4f8","z":"dc3259b7.f5bd38","name":"","env":[],"x":861.7734375,"y":198.15625,"wires":[["94067309.e00a"]]},{"id":"94d27430.3f8208","type":"inject","z":"dc3259b7.f5bd38","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":660.7734298706055,"y":198.56249809265137,"wires":[["5073cfef.7fabf"]]},{"id":"94067309.e00a","type":"debug","z":"dc3259b7.f5bd38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1095.773494720459,"y":195.3437557220459,"wires":[]}]

```

I wanted to write this post as a speficific feature request, but my original question about this can be found here: [Why does importing a clipboard with a subflow create a "new" identical but renamed subflow](https://discourse.nodered.org/t/why-does-importing-a-clipboard-with-a-subflow-create-a-new-identical-but-renamed-subflow/15668)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 September 2019 06:15 UTC](https://discourse.nodered.org/t/import-a-flow-containing-a-subflow-without-unintentionally-creating-a-duplicate-subflow/15683/2 "2019-09-19T06:15:12Z")

</div>

To repeat what I said in your other topic about this:

> [@Why does importing a clipboard with a subflow create a "new" identical but renamed subflow](https://discourse.nodered.org/t/why-does-importing-a-clipboard-with-a-subflow-create-a-new-identical-but-renamed-subflow/15668/3):
>
> There is a plan to do a better job of this in the future - to let the user choose whether to import it as a copy, use the existing subflow definition, or replace the existing definition with the one being imported.

---

<div class="post-metadata">

**Author:** ![cuxcrider](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@cuxcrider](https://discourse.nodered.org/u/cuxcrider)\
**Post date:** [18 November 2020 22:08 UTC](https://discourse.nodered.org/t/import-a-flow-containing-a-subflow-without-unintentionally-creating-a-duplicate-subflow/15683/3 "2020-11-18T22:08:35Z")

</div>

I tested this again using Node-RED version 1.2 and I no longer get a duplicate subflow. Thanks so much for the update!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 November 2020 00:33 UTC](https://discourse.nodered.org/t/import-a-flow-containing-a-subflow-without-unintentionally-creating-a-duplicate-subflow/15683/4 "2020-11-19T00:33:43Z")

</div>


