I want to set a flow variable via a button when its pressed. Can't find any docs on the format for this button payload option and the usual format I'd use in a function node as below (and several variants I have tried) flags syntax error:
flow.set("BulbState","BulbOn")
Also tried without "flow." prefix in case that was automatically added by the node when using this option.
Hi @notnice
I assume you are talking about the ui_button
node from node-red-dashboard?
Assuming it is, the payload is the value you want the node to send via a message. That's all. It doesn't provide a way to set a context value directly.
If you want that payload value to be set into context, wire the button node to a Change node configured to set the flow context value.
Yes, in the UI Button using this option. To me it it looks like it should be able to set a variable directly.
You are selecting the value it should send in the message. By selecting the flow.
option you are telling the node to send a flow context value.
If you want to set a value in context, then as I said, you'd have to wire this node to a Change node.
Ah, got it - it only sends an existing named variable, not anew one. Thats a shame.
Thx for your quick response.
Could do with having such info documented
Well the info does already say
" Clicking the button generates a message with msg.payload
set to the Payload field. If no payload is specified, the node id is used.
"
it doesn't say anything about setting other fields - but nor does it mention that it doesn't make a cup of tea.
Semantics
If you know what it means then its understandable. To me it read that the message payload would be created with whatever parameters I entered.
I am now the wiser
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.