# Problem updating UI-Table

**URL:** <https://discourse.nodered.org/t/problem-updating-ui-table/78565>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, function-node\
**Created:** [21 May 2023 07:44 UTC](https://discourse.nodered.org/t/problem-updating-ui-table/78565 "2023-05-21T07:44:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![88bit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/88bit/32/79334_2.png) [@88bit](https://discourse.nodered.org/u/88bit)\
**Post date:** [21 May 2023 07:44 UTC](https://discourse.nodered.org/t/problem-updating-ui-table/78565/1 "2023-05-21T07:44:06Z")

</div>

Hi, I have unexpected results with the following code in a function node. I have a table node behind this function node, but the table only updates when I refresh the browser, so the data is getting there in the correct format, but for some reason, the table is not updating when new data arrives.

Any help would be greatly appreciated.

```auto
var distanceFromBle = Math.pow(10, (-54 - (msg.payload.brssi)) / (10 * 3.5)).toFixed(1);

tableData = flow.get("savedData") || [];

tableData.unshift({
    "bmac" : msg.payload.bmac,
    "apmac": msg.payload.apmac,
    "mymac": msg.payload.mymac,
    "ltime": msg.payload.ltime,
    "wrssi": msg.payload.wrssi,
    "brssi": msg.payload.brssi,
    "distance": distanceFromBle
});

if (tableData.length > 9) tableData.pop();

msg.payload = tableData;

flow.set("savedData", tableData);

return msg;

```

---

<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:** [21 May 2023 09:12 UTC](https://discourse.nodered.org/t/problem-updating-ui-table/78565/2 "2023-05-21T09:12:04Z")

</div>

I believe the issue is when you try to add a row, best use the command function addRow , there is info in the help text, there are also example flows in the import examples.

here is an example, i have hardcoded the incoming values, so you will need to edit

```auto
[{"id":"f772e294cac42fef","type":"ui_ui_control","z":"b9860b4b9de8c8da","name":"","events":"connect","x":100,"y":2960,"wires":[["4830d675874b086f"]]},{"id":"4830d675874b086f","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"savedData","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":2960,"wires":[["57590ede03d46c80"]]},{"id":"57590ede03d46c80","type":"ui_table","z":"b9860b4b9de8c8da","group":"2d4fe667.28f8ba","name":"","order":24,"width":0,"height":0,"columns":[],"outputs":0,"cts":false,"x":410,"y":3020,"wires":[]},{"id":"1340d3a79960f451","type":"function","z":"b9860b4b9de8c8da","name":"function 25","func":"let distanceFromBle = Math.pow(10, (-54 - (Math.random()*20)) / (10 * 3.5)).toFixed(1);\n\nlet tableData = flow.get(\"savedData\") || [];\nlet new_row = {\n \"bmac\": tableData.length,\n \"apmac\": 2,\n \"mymac\": 2,\n \"ltime\": 2,\n \"wrssi\": 2,\n \"brssi\": 2,\n \"distance\": distanceFromBle\n};\n\ntableData.unshift(new_row);\nif (tableData.length > 9) tableData.pop();\n\nmsg.payload = {\n command: \"addRow\",\n arguments: [\n new_row,\n true\n],\n returnPromise: true\n}\n\nflow.set(\"savedData\", tableData);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":3060,"wires":[["57590ede03d46c80","c896bb713eec327c"]]},{"id":"14ac1f7d6efe1fa3","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"one\":1,\"two\":2},{\"one\":4,\"two\":5}]","payloadType":"json","x":90,"y":3040,"wires":[["1340d3a79960f451"]]},{"id":"c896bb713eec327c","type":"debug","z":"b9860b4b9de8c8da","name":"debug 297","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":3080,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false,"className":""},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

[edit] Added Ui-control to load table on connect.

---

<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:** [4 June 2023 09:12 UTC](https://discourse.nodered.org/t/problem-updating-ui-table/78565/3 "2023-06-04T09:12:32Z")

</div>

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