# \[Feature Request\]Could nodes such as inject,change, switch etc have an option to copy an existing rule/property as well as the add button

**URL:** https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420
**Category:** General
**Created:** [10 April 2023 12:48 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420 "2023-04-10T12:48:48Z")
**Posts on this page:** 12
**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: [10 April 2023 12:48 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/1 "2023-04-10T12:48:48Z")

</div>

e.g a copy button next to the x

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/95928f42a8669a68747d0195df71f918b27631f5.png)

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 April 2023 13:03 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/2 "2023-04-10T13:03:53Z")

</div>

Or the add button could duplicate the latest rule rather than defaulting to  
Set msg.payload

---

<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: [10 April 2023 13:06 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/3 "2023-04-10T13:06:36Z")

</div>

I think we need both options really but 90% of the time, when I'm adding something - its very similar to the previous option (which is reason for this FR) 🙂

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 April 2023 13:24 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/4 "2023-04-10T13:24:15Z")

</div>

Gets my vote. I am all for simplifying UX. No one likes unnecessary clickage

> [@jbudd](#):
>
> Or the add button could duplicate the latest rule

This was my initial request some time ago & was implemented in the switch node only (and wasnt fully implemented the way i would have hoped - i.e. only the `typedInput` selection is duplicated on the next row).

#### Notes and thoughts if this proposal is accepted...

Ideally, I would like to see the `inject`, `switch` and `change` nodes duplicate all parts of the previous row to the new row.

This feature would be operated either by the existing "add" button or a _per row_ "Duplicate" button (as @cymplecy requested).

The newly created row should be focused after creation to aid keyboard navigation

A keyboard shortcut to operate this "duplicate row" would make adding entries 100% keyboard compatible. (since I also dislike context switching between keyboard and mouse - as it causes me to lose focus! I consider forced context switching poor UX)

---

<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: [10 April 2023 14:45 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/5 "2023-04-10T14:45:34Z")

</div>

sounds good - though not sure 100% duplication in an inject (or change) node makes sense - eg set msg.payload to foo - then set msg.payload to foo... I guess it's workable - but having to then delete payload and write topic (for example) is almost as much work. Also in the mockup shown, would copy/duplicate insert the new rule at that point ? (ie shuffle everything down) - or just add to the end (as the add button does).

---

<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: [10 April 2023 14:56 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/6 "2023-04-10T14:56:04Z")

</div>

> [@dceejay](#):
>
> Also in the mockup shown, would copy/duplicate insert the new rule at that point ? (ie shuffle everything down) - or just add to the end (as the add button does).

I think inserting it after the one being duplicated would be the most intuitive - its easy to move things around if it wasn't quite what was required

> [@dceejay](#):
>
> eg set msg.payload to foo - then set msg.payload to foo... I guess it's workable - but having to then delete payload and write topic (for example) is almost as much work

It might be same work if just simple set but saves work for a change

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/feb05acf6ef239983648359c4d49fd205f46bdda.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 April 2023 15:01 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/7 "2023-04-10T15:01:13Z")

</div>

> [@dceejay](#):
>
> sounds good - though not sure 100% duplication in an inject (or change) node makes sense

There may be a variation required for these nodes but my thought was initially "for consistency".

TBF: I dont mind deleting the duplicated value since pressing `delete` is far easier than re-typing `my-custom-long-prop-name` over and over again. Additionally, so long as the text is highlighted `on focus` the user can simply overtype anyhow 🤷

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 April 2023 15:03 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/8 "2023-04-10T15:03:25Z")

</div>

> [@Steve-Mcl](#):
>
> so long as the text is highlighted `on focus` the user can simply overtype

But which field gets focus - msg property, search for or change to?

---

<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: [10 April 2023 15:05 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/9 "2023-04-10T15:05:44Z")

</div>

> [@cymplecy](#):
>
> but saves work for a change

true - but not so true for an inject. - but yes - I would be happy to see a prototype along these lines (for v4).

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 April 2023 15:05 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/10 "2023-04-10T15:05:56Z")

</div>

The 1st changeable field (usually the operator or msg prop)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [10 April 2023 16:36 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/11 "2023-04-10T16:36:09Z")

</div>

> [@dceejay](#):
>
> sounds good - though not sure 100% duplication in an inject (or change) node makes sense - eg set msg.payload to foo - then set msg.payload to foo... I guess it's workable - but having to then delete payload and write topic (for example) is almost as much work.

I do have plenty of cases where inject is used for testing with some quite complex data and it would be very nice to be able to duplicate it and (manually) add a number to the end of the property name. So that it is then easy to switch between them.

Similarly with the change node - specifically when dealing with JSONata or a JSON input.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [9 June 2023 16:36 UTC](https://discourse.nodered.org/t/feature-request-could-nodes-such-as-inject-change-switch-etc-have-an-option-to-copy-an-existing-rule-property-as-well-as-the-add-button/77420/12 "2023-06-09T16:36:11Z")

</div>

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