# \[Feature Request\]Duplicate existing switch statements

**URL:** <https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268>\
**Category:** Feature Requests\
**Created:** [13 June 2020 08:32 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268 "2020-06-13T08:32:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [13 June 2020 08:32 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/1 "2020-06-13T08:32:35Z")

</div>

I'm doing a lot of Alexa phrase parsing nowadays and therefore using "contains" a lot.

It's very repetitive to having to keep going thru the sequence off adding new rule,selecting contains and retyping a complete string

As lots of times - the new string is similar to an existing one

It would be a much nicer to be able to just duplicate an existing action

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a66c55d7eae7e9091646ca8c7ef19a092fffc94d.png)

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [13 June 2020 17:54 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/2 "2020-06-13T17:54:56Z")

</div>

I would argue against duplicating the value text but the evaluation type and output data type would be convenient. At least I've found that in most cases they will be the same on all cases.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [13 June 2020 18:11 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/3 "2020-06-13T18:11:42Z")

</div>

I'd take any scraps that I can 🙂

But since I'm basically saying - lets have a copy as well as existing cut/paste insert that we currently have then, its going to more consistent to copy/paste insert a whole line I think

Plus it gives me what I want so less typing/copy/pasting for me 🙂

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [13 June 2020 20:35 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/4 "2020-06-13T20:35:53Z")

</div>

I now just realised I was talking about output data type while meaning the value in the evaluation field. Anyhow I would say the content in the evaluation field is what typically changes so it wouldn't make sense copying that. In your scenario you'd have the text on clipboard ready to paste on the next input field.

The "laborious" part is mousing through the two drop down menus IMO. 🙂

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [22 June 2020 13:28 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/5 "2020-06-22T13:28:18Z")

</div>

I had a recent issue similar to yours. I have a change node with 76 rules and by the time I got to 40 rules, it was becoming very tedious to do all that scrolling.

Plus, I discovered that my rule sequence was important because when a rule is satisfied, **the node continues scanning the rest of the rules.** (I thought the node would exit when a rule is satisfied). For example, I am entering the node with a (string)number and when found, change msg.payload to an information string to be displayed in a Text node on the dashboard. I originally sorted the rules from shortest to longest. I.E. 123 would come before 12345. The node changed 123 to the text string, but it continued scanning the node rules and changed the 123 in 12345 as well. I fixed this by putting the longest rules first.

But with 50+ nodes to move about, this became tedious quite quickly.  
My solution, and **a workaround for your issue** was to export the change node to a text file, then run the JSON data through [JSON Formatter tool](https://jsonformatter.curiousconcept.com/) to make it human readable. I then edited my rules in the text editor. When done, I imported the node back into Node Red.

Hope this helps.

---

<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:** [22 June 2020 13:31 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/6 "2020-06-22T13:31:44Z")

</div>

PS - in your settings file you can set `flowFilePretty: true,` to format the json for you.

---

<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:** [22 June 2020 13:35 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/7 "2020-06-22T13:35:13Z")

</div>

> [@SteveMann](#):
>
> Plus, I discovered that my rule sequence was important because when a rule is satisfied, **the node continues scanning the rest of the rules.** (I thought the node would exit when a rule is satisfied).

There is an option at the bottom of the edit dialog to either 'check all rules' (the default behaviour), or 'stopping after first match'.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [22 June 2020 13:38 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/8 "2020-06-22T13:38:43Z")

</div>

> [@knolleary](#):
>
> There is an option at the bottom of the edit dialog to either 'check all rules' (the default behaviour), or 'stopping after first match'.

![doh(300)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87843b5e2601623e7c23d314c2cb43b6da87c23a.jpeg)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 August 2020 13:38 UTC](https://discourse.nodered.org/t/feature-request-duplicate-existing-switch-statements/28268/9 "2020-08-21T13:38:44Z")

</div>

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