Accessing flow.variables

I'm a relative newbie, so apologies in advance if I'm framing a stupid question. I am saving a numeric value captured from a dashboard slider as flow.low - and a debug node shows it saved (as expected) with a numeric value of 5. In a subsequent node setup for testing purposes, I simply set msg.payload to flow.low and attach a debug node. The debug node shows the value as "undefined". What am I doing wrong?

The relevant nodes are as follows, first for setting the value in a "change" node ...

In a subsequent function node, there are just two lines:

msg.payload=flow.low

return msg;

Thanks in anticipation for any tips about what I am doing wrong!

Welcome to the forum.

Try using flow.get & flow.set Writing Functions : Node-RED

Many thanks! That works, though I’m unsure why the original code failed.

Whilst this may work sometimes, it is not guaranteed. flow.low attempts to directly access the in-memory version of flow. This has not been recommended for a very long time. As Steve has suggested, you should use the getter and setter functions in function nodes which guarantees correct access.

Nodes such as the change node use the getters and setters behind the scenes as well.