# Help with global context and building messages with it in \`change\` node

**URL:** <https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681>\
**Category:** General\
**Created:** [15 January 2023 04:20 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681 "2023-01-15T04:20:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 January 2023 04:20 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681/1 "2023-01-15T04:20:42Z")

</div>

I may need to use a different node. I get that.

Dating back to when I started to use context, I didn't think think of this _new_ problem.

Ok, here is a screen shot of what I have - with comments.

As is, I set the path. It is _hard coded_ which I now see as a problem.  
So I added the new line but don't know if a `change` node can facilitate what I am wanting to do.

 ![Screenshot from 2023-01-15 15-06-53](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60b9e952ca0edbaa9b0a99bf16998651adacd9a9.png)

The `9020-9C27` is fixed and if it needs to be changed, I have to edit two lines.  
(Yeah, not the end of the world)

So I _define_ that part as `usb_path` and want to use that in the two lines below, that way I only have to change ONE line.  
Sorry if it is being anal, but just now that is sort of stuck in my head as a _better way_ to do things.

Or will have to use a `template` node then set the `context` after it?

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [15 January 2023 07:17 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681/2 "2023-01-15T07:17:49Z")

</div>

Does this work ?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/7/17672fe811d7b8a50990fca954955a000bfce105.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 January 2023 07:19 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681/3 "2023-01-15T07:19:27Z")

</div>

I'll give it a go.

I was hoping to not need to use/get another node, but if it needs one, it needs one.

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [15 January 2023 07:22 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681/4 "2023-01-15T07:22:26Z")

</div>

it is not _another_ node, it can be in the same change node, that you have shown.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 January 2023 07:24 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681/5 "2023-01-15T07:24:07Z")

</div>

To clarify @smanjunath211 - when you use a change node and set a new property, you can immediately use it from the lines that were defined above (really useful). (just like you can in a function node, as that is what happens "underwater")

---

<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:** [29 January 2023 07:25 UTC](https://discourse.nodered.org/t/help-with-global-context-and-building-messages-with-it-in-change-node/73681/6 "2023-01-29T07:25:00Z")

</div>

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