# How to send a object by button click

**URL:** <https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524>\
**Category:** General\
**Created:** [17 February 2022 09:31 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524 "2022-02-17T09:31:28Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)\
**Post date:** [17 February 2022 09:31 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/1 "2022-02-17T09:31:28Z")

</div>

By clicking on the button I want send this object :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8b8b94dd37fd4335cebb2995d6d529f78125f33f.png)  
not sure if i can do it directly in button properties:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f2d56dcfdd68e033cadf6cc49781ecd6551014dc.png)

---

<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:** [17 February 2022 09:52 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/2 "2022-02-17T09:52:26Z")

</div>

I asked this question a couple of times, but had no response. As a work around you can pass it in the topic, by moving it to topic and after button moving it back.  
e.g.

```auto
[{"id":"4e4030f2.dfd108","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_test","payload":"{\"test\":1}","payloadType":"json","x":200,"y":840,"wires":[["4484635c.03cf24"]]},{"id":"4484635c.03cf24","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"[$$.topic,$$.payload]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":840,"wires":[["6c09a28.a79875c"]]},{"id":"6c09a28.a79875c","type":"ui_button","z":"bf9e1e33.030598","name":"","group":"2d4fe667.28f8ba","order":23,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":630,"y":840,"wires":[["5741f42.5864a0c"]]},{"id":"5741f42.5864a0c","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"topic[1]","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"topic[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":900,"wires":[["1923b48a.75b083"]]},{"id":"1923b48a.75b083","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":900,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)\
**Post date:** [17 February 2022 09:54 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/3 "2022-02-17T09:54:32Z")

</div>

I'm thinking to send by button click a buffer and then with parse buffer do what I need, but is there any more easy way ?

```auto
[{"id":"b23eb81b5d848a85","type":"debug","z":"bc76ab2f.9bc068","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":2880,"wires":[]},{"id":"cd57c6f61719fffc","type":"ui_button","z":"bc76ab2f.9bc068","name":"","group":"3da36874.a9b2c8","order":3,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"[\"0x10\",\"0x01\",\"0xD2\",\"0xFF\"]","payloadType":"bin","topic":"topic","topicType":"msg","x":440,"y":2880,"wires":[["533f2e74ea7508a4"]]},{"id":"533f2e74ea7508a4","type":"buffer-parser","z":"bc76ab2f.9bc068","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint8","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"item2","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"item3","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"item4","offset":3,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":610,"y":2880,"wires":[["b23eb81b5d848a85"]]},{"id":"3da36874.a9b2c8","type":"ui_group","name":"Hosté","tab":"befeb13c.bfa17","order":1,"disp":true,"width":4,"collapse":false,"className":""},{"id":"befeb13c.bfa17","type":"ui_tab","name":"TOPENÍ ETATHERM","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<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:** [17 February 2022 10:06 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/4 "2022-02-17T10:06:38Z")

</div>

If the buffer is static just enter it in the payload field after selecting buffer,. If it is dynamic and a incoming payload, you will have to do as in example above.  
If this does not answer your query, then please explain a bit more what you are trying to do.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 February 2022 10:09 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/5 "2022-02-17T10:09:28Z")

</div>

if you litterialy want to pass that data, select the 'json' option

 ![Screen Shot 2022-02-17 at 5.07.15 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/382c43edf78856cb78378d74e77e87447f55089d.png)  
This is the output:  
 ![Screen Shot 2022-02-17 at 5.09.10 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/8561e4fa026a3f15909bb6a6259f959fdab41cba.png)

---

<div class="post-metadata">

**Author:** ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)\
**Post date:** [17 February 2022 15:02 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/6 "2022-02-17T15:02:28Z")

</div>

and Hexadecimal ? This : {"DLE":0x00,"SOH":0x00,"BUSH":0x00}  
isn't working

---

<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:** [17 February 2022 15:25 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/7 "2022-02-17T15:25:23Z")

</div>

That is not valid JSON.

```auto
{"DLE":0,"SOH":0,"BUSH":0}

```

This is ☝

---

<div class="post-metadata">

**Author:** ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)\
**Post date:** [17 February 2022 15:27 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/8 "2022-02-17T15:27:10Z")

</div>

yes, but 0xDC no chance to send directly

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [17 February 2022 15:34 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/9 "2022-02-17T15:34:34Z")

</div>

> [@alda](#):
>
> {"DLE":0x00,"SOH":0x00,"BUSH":0x00}

You could send like this - {"DLE":"0x00","SOH":"0x00","BUSH":"0x00"}

---

<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:** [17 February 2022 15:39 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/10 "2022-02-17T15:39:24Z")

</div>

> [@alda](#):
>
> 0xDC

0xDC is simply 220. Use that if hard coded

Or, if dynamic, you can convert to integer using `parseInt('0xDC')`

---

<div class="post-metadata">

**Author:** ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)\
**Post date:** [17 February 2022 15:44 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/11 "2022-02-17T15:44:54Z")

</div>

ok, I will stay with this solution:

```auto
[{"id":"4938353d0b0cc294","type":"ui_button","z":"bc76ab2f.9bc068","name":"","group":"8c11279992e11f1f","order":5,"width":6,"height":1,"passthru":false,"label":"test","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"[\"0x00\",\"0x00\",\"0x00\",\"0x00\",\"0x11\",\"0x23\",\"0x00\",\"0x19\",\"0x00\",\"0x00\",\"0x00\",\"0x00\",\"0x00\",\"0x00\",\"0x00\"]","payloadType":"bin","topic":"topic","topicType":"msg","x":410,"y":2960,"wires":[["c10b57cd21eab1a3"]]},{"id":"c10b57cd21eab1a3","type":"buffer-parser","z":"bc76ab2f.9bc068","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint8","name":"DLE","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"SOH","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"BUSH","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"BUSL","offset":3,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"RAMH","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"RAML","offset":5,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"DC","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"D0_TMP_data","offset":7,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"D1_STime","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"D2_STime","offset":9,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"D3_ETime","offset":10,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"D4_ETime","offset":11,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"ADDS","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"XORS","offset":13,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"END","offset":14,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":true,"setTopic":false,"outputs":1,"x":690,"y":3000,"wires":[[]]},{"id":"8c11279992e11f1f","type":"ui_group","name":"OPERATIVNÍ ZMĚNY","tab":"befeb13c.bfa17","order":41,"disp":true,"width":6,"collapse":false,"className":""},{"id":"befeb13c.bfa17","type":"ui_tab","name":"TOPENÍ ETATHERM","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

With this I can send different instructions from different sources

---

<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:** [18 April 2022 15:45 UTC](https://discourse.nodered.org/t/how-to-send-a-object-by-button-click/58524/12 "2022-04-18T15:45:30Z")

</div>

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