# Variable in ui Table

**URL:** <https://discourse.nodered.org/t/variable-in-ui-table/21977>\
**Category:** General\
**Created:** [19 February 2020 11:43 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977 "2020-02-19T11:43:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![maku12](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maku12](https://discourse.nodered.org/u/maku12)\
**Post date:** [19 February 2020 11:43 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/1 "2020-02-19T11:43:35Z")

</div>

Hi, i have a ping node which gives me an online or offline value for the appropriate ip address of the device.  
Now i want to display this online or offline value in the ui\_table (json formatted inject node), but I don't know how to code this.

Please advise.

`[{"id":"c7374ff9.059fd8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5817a1ca.2f84a","type":"ping","z":"c7374ff9.059fd8","name":"minirouter (192.168.1.1)","host":"192.168.1.1","timer":"20","x":290,"y":240,"wires":[["b652f75b.8700e"]]},{"id":"83a869be.6eddc8","type":"debug","z":"c7374ff9.059fd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1050,"y":240,"wires":[]},{"id":"4f1b85ea.5eef1c","type":"inject","z":"c7374ff9.059fd8","name":"","topic":"","payload":"[{\"device\":\"Router\",\"ipaddress\":\"192.168.1.1\",\"status\":\"online\",\"url\":\"http://192.168.1.1\",\"aktion_1\":\"\",\"aktion_2\":\"\"},{\"device\":\"Sonoff Pow R2\",\"ipaddress\":\"192.168.1.196\",\"status\":\"online\",\"url\":\"http://192.168.1.196\",\"aktion_1\":\"\",\"aktion_2\":\"\"},{\"device\":\"Raspberry Pi\",\"ipaddress\":\"192.168.1.220\",\"status\":\"online\",\"url\":\"\",\"aktion_1\":\"Restart\",\"aktion_2\":\"Shutdown\"},{\"device\":\"Server\",\"ipaddress\":\"192.168.1.100\",\"status\":\"online\",\"url\":\"http://192.168.1.100\",\"aktion_1\":\"Wake on LAN\",\"aktion_2\":\"Shutdown\"}]","payloadType":"json","repeat":"5","crontab":"","once":true,"onceDelay":0.1,"x":290,"y":400,"wires":[["2a61ce21.cef162"]]},{"id":"2a61ce21.cef162","type":"ui_table","z":"c7374ff9.059fd8","group":"6990021c.cb4f1c","name":"Device List","order":1,"width":14,"height":5,"columns":[{"field":"device","title":"Gerät","width":"150","align":"left","formatter":"html","formatterParams":{"target":"_blank"}},{"field":"ipaddress","title":"IP Adresse","width":"120","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"status","title":"Status","width":"80","align":"center","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"url","title":"URL","width":"180","align":"left","formatter":"link","formatterParams":{"target":"_blank"}},{"field":"aktion_1","title":"","width":"100","align":"center","formatter":"link","formatterParams":{"target":"_blank"}},{"field":"aktion_2","title":"","width":"100","align":"center","formatter":"link","formatterParams":{"target":"_blank"}}],"outputs":0,"cts":false,"x":470,"y":400,"wires":[]},{"id":"d0153d0b.7f7f6","type":"comment","z":"c7374ff9.059fd8","name":"Network Device List","info":"","x":290,"y":340,"wires":[]},{"id":"b652f75b.8700e","type":"switch","z":"c7374ff9.059fd8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"lte","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":240,"wires":[["6a2b671e.739798"],["58c03eab.d428e"]]},{"id":"6a2b671e.739798","type":"function","z":"c7374ff9.059fd8","name":"online","func":"msg.payload = 'online'\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":220,"wires":[["3f02af01.c4236"]]},{"id":"58c03eab.d428e","type":"function","z":"c7374ff9.059fd8","name":"offline","func":"msg.payload = 'offline'\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":260,"wires":[["3f02af01.c4236"]]},{"id":"3f02af01.c4236","type":"function","z":"c7374ff9.059fd8","name":"","func":"minirouter = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":240,"wires":[["83a869be.6eddc8"]]},{"id":"6990021c.cb4f1c","type":"ui_group","z":"","name":"Default","tab":"bcbebf2b.5cc08","disp":false,"width":14,"collapse":false},{"id":"bcbebf2b.5cc08","type":"ui_tab","z":"","name":"Network","icon":"dashboard","order":8,"disabled":false,"hidden":false}]`

---

<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:** [19 February 2020 12:11 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/2 "2020-02-19T12:11:14Z")

</div>

Start by playing with theexamples that are provded with ui-table. If you go to [Ui-table node example](https://discourse.nodered.org/t/ui-table-node-example/21628/3) you can see how to get the examples.

---

<div class="post-metadata">

**Author:** ![maku12](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maku12](https://discourse.nodered.org/u/maku12)\
**Post date:** [19 February 2020 12:17 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/3 "2020-02-19T12:17:01Z")

</div>

Thanks, I know these examples, but I think this helps me not, because there are no variables but only values.  
I want to get a variable from another node into the json inject node

---

<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:** [19 February 2020 12:24 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/4 "2020-02-19T12:24:22Z")

</div>

You can not insert something into an inject node dynamically, but have you thought of connecting the ui-table note to the flow creating the data? You will probably need a change node to format the data info a format that the ui-table node needs and in the example nodes you have the format that is needed.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [19 February 2020 12:32 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/5 "2020-02-19T12:32:46Z")

</div>

Alternatively, save to flow context in a change node (coming out of that other node)  
Then inject from `flow.` with the variable you exported it to.

---

<div class="post-metadata">

**Author:** ![maku12](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maku12](https://discourse.nodered.org/u/maku12)\
**Post date:** [19 February 2020 12:40 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/6 "2020-02-19T12:40:34Z")

</div>

hmmm, sorry but I don't know what you mean, maybe you can show me in the flow I provided.

many Thanks

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [19 February 2020 12:46 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/7 "2020-02-19T12:46:18Z")

</div>

Here's some reading material to get you started: [https://nodered.org/docs/user-guide/context#what-is-context](https://nodered.org/docs/user-guide/context#what-is-context). In your situation, go for the "using context in flow" with the change node. Put that after your ping node output and save it to the flow context.

Then in the inject wherever you need it, select `flow.` followed by the name of the flow variable you picked. For example:

 ![Screenshot 2020-02-19 at 13.45.37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52c54c50ea3695408cfb3b63f0d46106d6269cd1.png)

---

<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:** [19 April 2020 12:46 UTC](https://discourse.nodered.org/t/variable-in-ui-table/21977/8 "2020-04-19T12:46:18Z")

</div>

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