# How to deliver variable value to different flow when ui-button is pressed

**URL:** <https://discourse.nodered.org/t/how-to-deliver-variable-value-to-different-flow-when-ui-button-is-pressed/65081>\
**Category:** General\
**Tags:** function-node\
**Created:** [14 July 2022 09:05 UTC](https://discourse.nodered.org/t/how-to-deliver-variable-value-to-different-flow-when-ui-button-is-pressed/65081 "2022-07-14T09:05:53Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![JackJackTan414](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JackJackTan414](https://discourse.nodered.org/u/JackJackTan414)\
**Post date:** [14 July 2022 12:23 UTC](https://discourse.nodered.org/t/how-to-deliver-variable-value-to-different-flow-when-ui-button-is-pressed/65081/3 "2022-07-14T12:23:49Z")

</div>

Sorry for the misunderstanding, As you can see from my overall flow here, the button node here is suppose to act like a gate which before it is pressed, no value will be able to pass through it to the function and save it to the MySQL data base.

please have a look at the code in this function node(after button node) , there is 1 line which consist both msg.topic and msg.payload.

Since button can only send msg.topic and msg.payload, lets say if i were to write the code like this:-

**if(msg.topic=='pressed')**  
**{**  
**msg.topic = "INSERT INTO table1(`value`)VALUES(' " + msg.payload + " ');";**

**}**

**return msg;**

i wont get the value that i desired if i do if(msg.topic=='pressed') condition, my value will become a random string number in mySQL database

or the value turns out to be just "pressed" if i use if(msg.payload=="pressed") condition.

However, if i were to remove this button node, everything works fine.

This is my concept,I am planning to implement a dashboard whereby, if the end-user wants to record this reading, they just have to press the button and the data will be saved in a MYSQL database.

Once again, so sorry for causing a confusion.

Please refer to the image shown in this link.

> [@How can i mention my "ui-button" code in the function node when it is pressed?](https://discourse.nodered.org/t/how-can-i-mention-my-ui-button-code-in-the-function-node-when-it-is-pressed/64819/6):
>
> Hi, sorry for the misunderstanding. The msg.topic contains "variable" values that is generated through the OPC-UA client node. And i would like it to display the data on the MySQL database only when i press the button on the dashboard. The second image shows the code im trying to implement in the function node after the button node. This is what i meant by both the "msg.topic" and "msg.payload" are pre-occupied with values. The third image is part of the configuration page of the ui-button nod…

---

_[View the full topic](https://discourse.nodered.org/t/how-to-deliver-variable-value-to-different-flow-when-ui-button-is-pressed/65081)._
