# UI Button with dynamic topic based on state

**URL:** https://discourse.nodered.org/t/ui-button-with-dynamic-topic-based-on-state/14003
**Category:** General
**Created:** [4 August 2019 22:09 UTC](https://discourse.nodered.org/t/ui-button-with-dynamic-topic-based-on-state/14003 "2019-08-04T22:09:11Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 August 2019 22:21 UTC](https://discourse.nodered.org/t/ui-button-with-dynamic-topic-based-on-state/14003/2 "2019-08-04T22:21:19Z")

</div>

You might find the `template` node useful.

E.g.

```auto
UPDATE schedule SET weekend_off = {{payload}} WHERE ID = '{{flow.my_id}}'

```

You can access msg, flow and global variables. Read the help info on the side bar

---

_[View the full topic](https://discourse.nodered.org/t/ui-button-with-dynamic-topic-based-on-state/14003)._
