# Function nodes doing different things with different NR versions

**URL:** <https://discourse.nodered.org/t/function-nodes-doing-different-things-with-different-nr-versions/91174>\
**Category:** General\
**Created:** [21 September 2024 22:43 UTC](https://discourse.nodered.org/t/function-nodes-doing-different-things-with-different-nr-versions/91174 "2024-09-21T22:43:37Z")\
**Posts on this page:** 4\
**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:** [21 September 2024 22:43 UTC](https://discourse.nodered.org/t/function-nodes-doing-different-things-with-different-nr-versions/91174/1 "2024-09-21T22:43:37Z")

</div>

Following on from my other question about updating NR from 3.0.2 to 3.1.5....

I made a lump of code in a `function` node on the 3.1.5 machine.

In the `on start` tab I have:

```auto
// Code added here will be run once
// whenever the node is started.
context.set("counter", 0)
context.set("rounter_status", "unknown")
context.set("pip_status", "unknown")
context.set("modem_status", "unknown")
context.set("internet_status", "unknown")
node.status({ text: "RESET" })

```

And if I modify the code/node when I `DEPLOY` it says `RESET`.

I export it to a machine with 3.0.2 and that doesn't happen.

Is it a version problem or something else?

(off topic: I just saw the typo in the code I posted. But still... It doesn't seem to be done on the second machine. Right or wrong code.)

---

<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:** [21 September 2024 22:47 UTC](https://discourse.nodered.org/t/function-nodes-doing-different-things-with-different-nr-versions/91174/2 "2024-09-21T22:47:59Z")

</div>

The status will only be set once the function has received a msg. use debug nodes to confirm a msg was sent to the function.

---

<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:** [21 September 2024 22:51 UTC](https://discourse.nodered.org/t/function-nodes-doing-different-things-with-different-nr-versions/91174/3 "2024-09-21T22:51:44Z")

</div>

I think there is confusion with what/how I explained things.

(and now I'm trying to capture it: it is not playing the game.)

Ok, I'll have to fall on my sword again.

Sorry.

I maybe cried _Wolf_.

---

<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:** [21 September 2024 23:13 UTC](https://discourse.nodered.org/t/function-nodes-doing-different-things-with-different-nr-versions/91174/4 "2024-09-21T23:13:28Z")

</div>

Here is an example of what I see happening WRT the `on start` tab.

 ![Screenshot from 2024-09-22 09-09-08](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c7a62ca2bc83e59ddaf661c9516bc0dc79c6466.png)

A message was received and the `status` changed.

I edited some of the code in the node.  
I press DEPLOY

 ![Screenshot from 2024-09-22 09-09-59](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/980a6f6aaeba0c0b3c22fbf0b3f29ba9b331b92c.png)

Now you see that it is doing the `on start` code.  
Which it didn't seem to be happening before when I asked.

The code - again for clarity:

```auto
// Code added here will be run once
// whenever the node is started.
context.set("counter", 0)
context.set("router_status", "unknown")
context.set("pip_status", "unknown")
context.set("modem_status", "unknown")
context.set("internet_status", "unknown")
node.status({ text: "RESET" })

```

Most importantly the last line.

There are no other messages arriving.  
This is a controlled environment.
