Payload global. or flow

In many nodes you can select the payload to be global. or flow. ( as well as number, string, buffer....)

Can anyone please point to documentation or examples on how these are used. I've had no lock searching on my own.

Thank you

What you can actually select in those nodes is to make use of the incoming msg, or a context variable which might be a global or a flow variable.

payload is part of the incoming msg (it is a convention, it isn't mandated but is commonly used). e.g msg.payload.

Global context variables are available across all of your tabs and sub-flows.

Flow variables are available only in the tab that defines them.

I'm not sure you understood my question.
Take for example the ui button node. Under the line "When clicked send" you have options for payload and topic. I've used the other options but global. and flow. are a mystery to me.

I guess what I'm hoping is I can directly up a global or flow variable in the payload without having to add a function node.

Like this?
Untitled 9
I suppose if I needed to extract something more difficult from payload - a substring say, I'd use a function node.

Like this.


Hi @dsplitz

you asked for documentation, so the starting point is the docs on 'Context' - Working with context : Node-RED

This is what 'global' and 'flow' refer to - values that exist outside of any one particular message.

So let's say you have, in another flow, set global.color to the value "red". You can configure the ui_button node to send a message with its payload property set to the current value of global.color. That means you can dynamically change the value the button sends by changing the value in context.

Does that help answer your questions?

Awesome!! Thank you that answers it.


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