# \[Feature Request\]Set flow context directly in inject node

**URL:** https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299
**Category:** Feature Requests
**Created:** [20 November 2024 20:59 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299 "2024-11-20T20:59:58Z")
**Posts on this page:** 9
**Page:** 2

<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: [23 November 2024 10:18 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/21 "2024-11-23T10:18:10Z")

</div>

All depends which you are most comfortable with. Either is fine (especially if you label your nodes sensibly).

---

<div class="post-metadata">

### Author: ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)
#### Post date: [23 November 2024 11:50 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/22 "2024-11-23T11:50:56Z")

</div>

@zenofmud Just as dceejay pointed out, at this point I'm quite comfortable with JavaScript and often am setting multiple context variables or additional operations in the same function node. At first I heavily used the change node and did things the "Node-RED" way. TBH, I still use the change node when I'm just setting one or two vars due to it's simplicity, I just prefer being able to quickly copy/paste lines in the function node rather than having to select options over and over again for the change node. Perhaps I would like it more if the change node operated such that when you select a different option from the drop down (`msg.`, `flow.`, `global.`) adding additional rules items should keep the selected setting of the previous rule rather than defaulting to `msg.` every time.

Also while messing with the change node just now I realized it may have an unintended behavior. When placing a change node if I select the `flow.` or `global.` options then revert back to `msg.` it clears the text input box contents even though I don't want it to. Causing the user to spend additional time retyping the property names. IDK if this is intended of not?

---

<div class="post-metadata">

### Author: ![WP-Rue](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wp-rue/32/87264_2.png) [@WP-Rue](https://discourse.nodered.org/u/WP-Rue)
#### Post date: [24 November 2024 21:07 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/23 "2024-11-24T21:07:08Z")

</div>

For one time flow/global context I use

> **[node-red-contrib-config](https://flows.nodered.org/node/node-red-contrib-config)**
>
> A node-red node to set flow and global context values at start up.

.. quite often.

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [24 November 2024 21:35 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/24 "2024-11-24T21:35:02Z")

</div>

Just my own thought.

An inject node should be an inject node  
A change node should be a change node.

Inject being able to manipulate the context feels strange.

Whilst I can see the convenience in faster initialisation flows, my gut feeling is that I would always want to see the change node doing that.

Change : set/alter things  
Inject : Inject a message

🤷‍♂️

---

<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: [24 November 2024 21:39 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/25 "2024-11-24T21:39:38Z")

</div>

That's just what I want 🙂  
If my PR doesn't get traction - I'll be using this from now 🙂

---

<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: [24 November 2024 22:27 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/26 "2024-11-24T22:27:46Z")

</div>

Yes @marcus-j-davies , and an inject node with nothing downstream would be most odd visually as flows must start have a start and end.

---

<div class="post-metadata">

### Author: ![RvG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rvg/32/96613_2.png) [@RvG](https://discourse.nodered.org/u/RvG)
#### Post date: [25 November 2024 15:11 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/27 "2024-11-25T15:11:01Z")

</div>

> [@Steve-Mcl](#):
>
> something I _often_ do is setup an inject node, get everything working nicely, then have to recreate it as a change node when I want to "wire it up in an automation". For me, a far better FR would be the ability to convert an inject node to change node or the ability to copy rows from the inject and paste them into a change node

Quite. Done that often enough, that by now I always start with inject + change, even when I don't expect to use flow variables.

---

<div class="post-metadata">

### Author: ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)
#### Post date: [29 November 2024 11:48 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/28 "2024-11-29T11:48:28Z")

</div>

> [@cymplecy](#):
>
> Could we have option to set all the contexts (msg/flow/global) in the inject node please?

At first site, I said: Yeah! Great idea 🙂  
... but after a while I realised:

- An inject is inject **only** , just like a "ping". Would be confusing, (especially for newbees,) if there would be something "hidden inside".

- What happens if I have to copy the flow with basic component back to a previous version of Node-Red ?

## This would totally break backward compatibility. ☹

_(Somebody just asked here recently that NR should be stability and "industrial-focused" in sense of not breaking things at every new version. I agree!)_

---

<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: [28 January 2025 11:49 UTC](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299/29 "2025-01-28T11:49:08Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/feature-request-set-flow-context-directly-in-inject-node/93299.md?page=1)
