# Click on button

**URL:** https://discourse.nodered.org/t/click-on-button/35080
**Category:** Dashboard
**Created:** [30 October 2020 14:48 UTC](https://discourse.nodered.org/t/click-on-button/35080 "2020-10-30T14:48:05Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)
#### Post date: [30 October 2020 14:48 UTC](https://discourse.nodered.org/t/click-on-button/35080/1 "2020-10-30T14:48:05Z")

</div>

hello  
the button has the option when clicked send flow or global. Either nothing happens or I get the message invalid properties.  
Can you show me the correct necessary syntax?  
I have now switched a function behind the button to flow.set ( 'button1',true)  
With a lot of buttons these are many functions which probably are not necessary

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [30 October 2020 14:59 UTC](https://discourse.nodered.org/t/click-on-button/35080/2 "2020-10-30T14:59:42Z")

</div>

If you have `flow.set( 'button1',true)` and the value `true` is stored in context storage, Then set flow to button1. That will send `true` when pressed.

---

<div class="post-metadata">

### Author: ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)
#### Post date: [30 October 2020 15:08 UTC](https://discourse.nodered.org/t/click-on-button/35080/3 "2020-10-30T15:08:32Z")

</div>

config from button  
 ![button](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/415b28d0a2fc13f28da304a8f9c7dbb8a43b77e8.jpeg)

hello  
either I didn't understand your answer or we are talking at cross purposes.  
I want to configure this in the button see picture

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [30 October 2020 15:10 UTC](https://discourse.nodered.org/t/click-on-button/35080/4 "2020-10-30T15:10:27Z")

</div>

No just `button1`, the value `true` will be read form context storage, as that where `flow.set ( 'button1',true)` stored it. Also you stored it to flow not global `global.set('button1', true)`, if you want to use global context storage. Global will be available to all flows, while flow will only be available to the flow you stored it from.

---

<div class="post-metadata">

### Author: ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)
#### Post date: [30 October 2020 15:28 UTC](https://discourse.nodered.org/t/click-on-button/35080/5 "2020-10-30T15:28:22Z")

</div>

ok  
this is not a write, this is a **read** from flow or in shown in my picture global?  
I thought this was a send, because the headline says when clicked, send

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 October 2020 15:29 UTC](https://discourse.nodered.org/t/click-on-button/35080/6 "2020-10-30T15:29:55Z")

</div>

When you click it sends whatever you tell it to send. You have told it to send global.button1 so it gets the value from global context and sends that. If you want clicking the button to set the context then configure the button to send true (or whatever) and feed that into a Change node to set the global context.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [30 October 2020 15:35 UTC](https://discourse.nodered.org/t/click-on-button/35080/7 "2020-10-30T15:35:01Z")

</div>

To add, if you want to send `true` when clicked, the set it to boolean `true`. It is a send , it is just reading or inputing what you wish to send.

---

<div class="post-metadata">

### Author: ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)
#### Post date: [30 October 2020 15:45 UTC](https://discourse.nodered.org/t/click-on-button/35080/8 "2020-10-30T15:45:57Z")

</div>

ok now I got it.  
I did not know that.  
so it gets the value from global context and sends it.

My first step to ad a function to write a global was correct.  
THX

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 October 2020 16:59 UTC](https://discourse.nodered.org/t/click-on-button/35080/9 "2020-10-30T16:59:21Z")

</div>

> [@edstobi](#):
>
> My first step to ad a function to write a global was correct.

Except it is more efficient to use a Change node.  
However, if you have number of buttons all doing similar things, but with different context variables then you could configure the buttons to send the name of the context variable as a string and feed all the buttons into one Function node that uses the string in the payload to set the correct context variable. Then you only need one function node instead of a number of Change nodes.

---

<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: [13 November 2020 16:59 UTC](https://discourse.nodered.org/t/click-on-button/35080/10 "2020-11-13T16:59:30Z")

</div>

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