How do you set a 'node' context variable?

In the documentation it talks about the 'scope' of a particular context. Global and flow I understand, but not node. To set a flow context variable you use something like
flow.set("myData", msg.payload, "storeInFile");
and in the sidebar you can see the value.
21%20PM

There is an area to display Node context, but how do you set it? If I use
node.set("myData", msg.payload);
I get:
28 Sep 00:52:14 - [error] [function:Node Stored in memory] TypeError: node.set is not a function
so my question: How do you set a node context?

1 Like
context.set("myData", msg.payload);

https://nodered.org/docs/writing-functions#storing-data

1 Like

Duh (head slap) I must have read that 3 times and it went in and out my head. (Can I blame my head cold?)
Thanks @knolleary !

@knolleary
One more question - when I use context.set("myData", msg.payload); It will only show up in the sidebar if I hi-light the node that created it. As soon as I click another node of even click somewhere else on the page, the entry in the sidebar disappears. It will come back if I click on the node and press the refress icon in the sidebar.

Is this expected behavior?

(I'm putting together example flows that might be good for the cookbook.)

Yes, as the name "node context" implies the context is only valid for that node.