# Use "flow." payload in Button node

**URL:** https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867
**Category:** General
**Created:** [1 May 2020 13:15 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867 "2020-05-01T13:15:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)
#### Post date: [1 May 2020 13:15 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/1 "2020-05-01T13:15:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [1 May 2020 13:20 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/2 "2020-05-01T13:20:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)
#### Post date: [1 May 2020 13:23 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/3 "2020-05-01T13:23:52Z")

</div>

Yes, in the UI Button using this option. To me it it looks like it should be able to set a variable directly.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a694ef9c8662c0a8eecabdcecaa9b93dba510eb4.png)

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [1 May 2020 13:38 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/4 "2020-05-01T13:38:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)
#### Post date: [1 May 2020 13:55 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/5 "2020-05-01T13:55:07Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [1 May 2020 14:39 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/6 "2020-05-01T14:39:23Z")

</div>

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. 😉

---

<div class="post-metadata">

### Author: ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)
#### Post date: [1 May 2020 17:28 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/7 "2020-05-01T17:28:37Z")

</div>

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 👍

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [30 June 2020 17:28 UTC](https://discourse.nodered.org/t/use-flow-payload-in-button-node/25867/8 "2020-06-30T17:28:45Z")

</div>

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