# Change node documentation wrong?

**URL:** <https://discourse.nodered.org/t/change-node-documentation-wrong/97355>\
**Category:** General\
**Created:** [31 May 2025 23:46 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355 "2025-05-31T23:46:06Z")\
**Posts on this page:** 20\
**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:** [31 May 2025 23:46 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/1 "2025-05-31T23:46:06Z")

</div>

Folks,

I'm trying to use a `change` node to get a global context value and not having luck.

Looking at:  
[how to get global context in change node](https://www.google.com/search?q=node-red+change+node+javascript+global+context&client=ubuntu-sn&hs=e6u&sca_esv=894da33211f3edad&channel=fs&sxsrf=AE3TifNrbw738cbNgg7xywyVmGWsfbIN1A%3A1748734287491&ei=T5E7aJjUHfSI0PEP9Maq-Qk&oq=node-red+change+node+javascript+&gs_lp=Egxnd3Mtd2l6LXNlcnAiIG5vZGUtcmVkIGNoYW5nZSBub2RlIGphdmFzY3JpcHQgKgIIADIFECEYoAEyBRAhGKABMgUQIRigAUjje1DcBliqWnABeAGQAQCYAaIDoAGhM6oBCDItMTYuNi4xuAEByAEA-AEBmAIYoALWNMICChAAGLADGNYEGEfCAgQQIxgnwgIKEAAYgAQYFBiHAsICBRAAGIAEwgIGEAAYFhgewgIIEAAYFhgKGB7CAgsQABiABBiGAxiKBcICCBAAGIAEGKIEwgIFEAAY7wXCAgYQABgNGB7CAgcQIRigARgKmAMAiAYBkAYIkgcKMS4wLjE1LjcuMaAHoYkBsgcIMi0xNS43LjG4B8o0wgcIMC4yLjE3LjXIB40B&sclient=gws-wiz-serp)

And I now see that it has been answered as I had fallen for this in the past.  
That is NOT the problem.

The documentation is not correct.  
Now I'm saying the documentation is WRONG.

What I need is `J: $globalContext('name')`

But the link above says:

`To: J: global.get('myGlobalVar') `

Which doesn't work.

SHOULD IT BE CHANGED?  
_By whom?_

---

<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:** [1 June 2025 00:20 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/2 "2025-06-01T00:20:53Z")

</div>

Of course you are right that the jsonata syntax which works is `$globalContext('name')`

`global.get('myGlobalVar')` is javascript syntax and works in a function node.

> [@Trying\_to\_learn](#):
>
> But the link above

Your link gives me a google search reply, it;s not clear which actual document has the bad advice?  
But the sentence you searched for `node-red change node javascript global context` is ambiguous because the J: option in the change node is for Jsonata not javascript .

One more thing - why can't you access the context variable using the "global" dropdown? Maybe you are intending a more complex Jsonata operation upon the returned value?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6dc0fd2ce3d6dde0902b4a97e1736a4f7406a208.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:** [1 June 2025 00:25 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/3 "2025-06-01T00:25:06Z")

</div>

Ok, thanks.

I was wanting to .... _modify_ the value. Not just get it.

So I wanted twice the global value.

Which can't be done _natively_ in the `change` node.

So _you_ have to go to the **J:** mode.

So it would be `J: global.get('name') *2)` - for instance.

But that gives me nothing.

So I dug around and found that I have to do it as shown:  
`J: $global.get('name') * 2`

And that works.

Sorry I didn't qualify that when I posted. I'm sorting stuff and this is the background task.

---

<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:** [1 June 2025 00:31 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/4 "2025-06-01T00:31:14Z")

</div>

I too have occasionally used jsonata expressions in a change node for simple calculations.  
I _always_ struggle to make it work.

Jsonata is undoubtedly powerful but the syntax is just too obscure for me.

These days I'm more likely to use javascript in a function node.  
I'm no expert on javascript but at least I stand a chance of getting it to work!

---

<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:** [1 June 2025 00:34 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/5 "2025-06-01T00:34:48Z")

</div>

I am only mentioning this as in the past when I've used `function` nodes to do such things, people have suggested I use he `change` node - as it is more _light weight_ for doing that sort of thing.

But now - it seems - some of the workings under the hood have changed.

MAYBE the original would work if I was not doing anything more than simply getting the value.

But as the second way (`J: $global.get('name') *2`) works (be it with or without the `* 2` bit....  
Standardise it to be the way documented then if the _future_ when people increase their need on what it does: they don't need to learn a new structure.

🤷

Just a thought.

All good though.

---

<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:** [1 June 2025 00:46 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/6 "2025-06-01T00:46:03Z")

</div>

> [@Trying\_to\_learn](#):
>
> people have suggested I use the `change` node - as it is more _light weight_

Well maybe it is but I'm not convinced!

> [@Trying\_to\_learn](#):
>
> dug around and found that I have to do it as shown:  
> `J: $global.get('name') * 2`  
> And that works.

That syntax does not work in a change node for me.

This

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1db73da5e7cda45998089cbecfd84e727a071486.png)  
gives me `undefined`

while this

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8ef6ac8bf0e40a4343847970b008e70b93d8b954.png)  
gives me 198

---

<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:** [1 June 2025 00:47 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/7 "2025-06-01T00:47:43Z")

</div>

I'm doing MR 4.0.9

You?

Sorry, just so we both know.

 ![Screenshot from 2025-06-01 10-48-48](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c119ff76630d742a7139a2ec5601347e9861d0b8.png)

# SORRY!

Ok, we do both agree.

That's what I'm saying.

The docs say the one that doesn't work.

So I think they should be corrected ASAP

---

<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:** [1 June 2025 06:11 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/8 "2025-06-01T06:11:23Z")

</div>

> [@Trying\_to\_learn](#):
>
> The docs say the one that doesn't work

What docs?

> [@jbudd](#):
>
> Your link gives me a google search reply, it;s not clear which actual document has the bad advice?

---

<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:** [1 June 2025 07:01 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/9 "2025-06-01T07:01:40Z")

</div>

Well, this is what I am seeing.

 ![Screenshot from 2025-06-01 17-00-05](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8afffb34f3773052af35d6948301c713fd6c25d.png)

It is written there.

Sorry, I didn't scroll down far enough.

Try this one.

Just a bit lower in the text from what I just posted/showed.

 ![Screenshot from 2025-06-01 17-28-52](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f2533a054caa3bc8662262f658f1a37330b02df7.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 June 2025 07:55 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/10 "2025-06-01T07:55:45Z")

</div>

That is talking about a Function node, which uses javascript. Also that is not node-red documentation, that is google AI.

---

<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:** [1 June 2025 08:01 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/11 "2025-06-01T08:01:59Z")

</div>

Not how I read the page.

At the top it is talking about the `change` node.

Then it goes to how to access contexts... (yech, bad word)

Ok: my bad.

I probably shouldn't trust google AI.

# SORRY FOLKS.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [1 June 2025 08:27 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/12 "2025-06-01T08:27:05Z")

</div>

The hint at the top of your fist image is "AI Overview" which translates to "made up bull shit, please ignore"

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 June 2025 09:37 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/13 "2025-06-01T09:37:35Z")

</div>

Read the words, it is perfectly correct, it says:  
'You can also access global context variables within a **function node** using ...'  
Function node, not Change node.

> [@hardillb](#):
>
> "AI Overview" which translates to "made up bull shit, please ignore"

I think that is going too far, I think better would be 'take it with a pinch of salt`. In fact it is usually frighteningly accurate.

---

<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:** [1 June 2025 09:42 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/14 "2025-06-01T09:42:55Z")

</div>

Well, thanks all....

I have got it working.

I just wanted to check on the validity of the documentation.

Oh, just to add:

```auto
[{"id":"31a9067d8b0ac069","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":780,"y":500,"wires":[["fb7426b3870c451a"]]},{"id":"fb7426b3870c451a","type":"change","z":"65c9b63cb09879a0","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"test","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":500,"wires":[["0d935bbe350562b5"]]},{"id":"0d935bbe350562b5","type":"debug","z":"65c9b63cb09879a0","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1170,"y":500,"wires":[]},{"id":"61e1fd3f6a0ed1d1","type":"change","z":"65c9b63cb09879a0","name":"","rules":[{"t":"set","p":"test","pt":"global","to":"20","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"$globalContext('test') * 2","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":570,"wires":[["f083ffb87d2e9be0"]]},{"id":"5b5b153ff9a3c119","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":780,"y":570,"wires":[["61e1fd3f6a0ed1d1"]]},{"id":"f083ffb87d2e9be0","type":"debug","z":"65c9b63cb09879a0","name":"debug 12","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1170,"y":570,"wires":[]},{"id":"89eb6a476a8c3345","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":780,"y":450,"wires":[["71aeac5dd2337c08"]]},{"id":"71aeac5dd2337c08","type":"change","z":"65c9b63cb09879a0","name":"","rules":[{"t":"set","p":"test","pt":"global","to":"44","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":450,"wires":[[]]}]

```

BOTH of these work. Given I do the first `inject` before trying to use the second one the first time around - or..... that `global:test` is set.

---

<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:** [1 June 2025 12:00 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/15 "2025-06-01T12:00:50Z")

</div>

> "made up bull shit, please ignore"

Unless you are living under a rock, you are gravely mistaken, plus that it is 100% correct with its response.

Come to think of it (offtopic) - why does the node-red repo not have a AI-bot to help out with the issues and PR's ? I have come across several repo's where issues are being picked up by AI bots with auto-PR's.

---

<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:** [1 June 2025 12:40 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/16 "2025-06-01T12:40:25Z")

</div>

It is indeed correct when it says  
 ![Screenshot 2025-06-01 at 13.36.51](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/01bbc09dac797ec127e149b4647f0f4b1087f50d.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 June 2025 13:01 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/17 "2025-06-01T13:01:16Z")

</div>

Though that is of course a universal truth, not limited to AI.  
Even the official node-red docs no doubt have some mistakes

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [1 June 2025 14:22 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/18 "2025-06-01T14:22:39Z")

</div>

> [@Trying\_to\_learn](#):
>
> validity of the documentation

As other have said this is an AI response, so nothing to do with Node-Red docs, BUT it reads correct to me anyway ?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [1 June 2025 14:40 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/19 "2025-06-01T14:40:08Z")

</div>

> Come to think of it (offtopic) - why does the node-red repo not have a AI-bot to help out with the issues and PR's ? I have come across several repo's where issues are being picked up by AI bots with auto-PR's.

And you are volunteering to check and test all this AI generated code?

---

<div class="post-metadata">

**Author:** ![maxwellhadley](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxwellhadley/32/7827_2.png) [@maxwellhadley](https://discourse.nodered.org/u/maxwellhadley)\
**Post date:** [1 June 2025 14:46 UTC](https://discourse.nodered.org/t/change-node-documentation-wrong/97355/20 "2025-06-01T14:46:51Z")

</div>

> [@Colin](#):
>
> I think that is going too far, I think better would be 'take it with a pinch of salt`. In fact it is usually frighteningly accurate.

But sometimes merely frightening

[Next page](https://discourse.nodered.org/t/change-node-documentation-wrong/97355.md?page=2)
